[postgis-users] Has anyone got novel Python function example

Imre Samu pella.samu at gmail.com
Sat Dec 3 20:10:15 PST 2022


> It will be interesting to see novel Python functions in PostGIS.

Server side?

1. Postgis Raster  see
  "11.3.4. Use PLPython to dump out images via SQL"
  https://postgis.net/docs/using_raster_dataman.html

2.) book:   "PostGIS-Cookbook"
https://www.packtpub.com/product/postgis-cookbook-second-edition/9781788299329
 - "Writing PostGIS functions with PL/Python"

https://github.com/PacktPublishing/PostGIS-Cookbook-Second-Edition/blob/master/Chapter08/code%20snippets/chp08_R4.sql
 -  "Geocoding with geopy and PL/Python"

https://github.com/PacktPublishing/PostGIS-Cookbook-Second-Edition/blob/master/Chapter08/code%20snippets/chp08_R7.sql

3.) The plpygis has some simple examples:
https://plpygis.readthedocs.io/en/latest/examples.html
"plpygis is a Python conveter to and from the PostGIS geometry type, WKB,
EWKB, GeoJSON and Shapely geometries and additionally supports
__geo_interface__. plpygis is intended for use in PL/Python functions."
see more:
-  https://plpygis.readthedocs.io/en/latest/
-  https://github.com/bosth/plpygis
-  slide ( 2017 )
https://2017.foss4g.org/post_conference/Extending-PostGIS-with-Python.pdf

4.)  CartoDB is also plpythonu based.
- https://github.com/search?q=repo%3ACartoDB%2Fcartodb+plpython&type=code
- crankshaft ( CARTO Spatial Analysis extension for PostgreSQL )
https://github.com/CartoDB/crankshaft

5.)  (tutorial) Map Matching in PostGIS with Valhalla and PL/Python
https://gis-ops.com/map-matching-postgis-plpython/

6.) Apache MADlib ( Graph, Deep learning, Statistics,  .. )
https://madlib.apache.org/docs/latest/index.html   ( mostly plpythonu based
)

....

Be careful:
*"PL/Python is only available as an “untrusted” language, meaning it does
not offer any way of restricting what users can do in it and is therefore
named plpython3u. A trusted variant plpython might become available in the
future if a secure execution mechanism is developed in Python. The writer
of a function in untrusted PL/Python must take care that the function
cannot be used to do anything unwanted, since it will be able to do
anything that could be done by a user logged in as the database
administrator. Only superusers can create functions in untrusted languages
such as plpython3u."*
https://www.postgresql.org/docs/15/plpython.html
https://dba.stackexchange.com/questions/132352/why-is-pl-python-untrusted


Regards,
 Imre


Shaozhong SHI <shishaozhong at gmail.com> ezt írta (időpont: 2022. dec. 3.,
Szo, 21:59):

> It will be interesting to see novel Python functions in PostGIS.
>
> Regards,
> David
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20221204/c8b6db45/attachment.htm>


More information about the postgis-users mailing list