Database Reference
In-Depth Information
ST_GeomFromText('POINT(-73.992809
40.688774)', 4326)CONTEXT: PL/Python
function "geocode2"
geocode2
----------------------------------------------------0101000020E61000002A8BC22E8A7F52C0E52A16BF29584440
(1 row)
6. As a bonus step, create a table in PostgreSQL with street addresses, and
generateanewpointPostGISlayerstoringthegeocodedpointsreturnedby
the Geocode function.
How it works...
YouwroteaPL/Pythonfunctiontogeocodeanaddress.Forthispurpose,youused
the geopy Python library that let you query several geocoding APIs in the same
manner.
Usinggeopy,youneedtoinstantiatea geocoder objectwithagivenAPIandquery
it to get the results such as a place name and a couple of coordinates. You can
use the plpy module utilities to run a query to the database using the PostGIS
ST_GeomFromText function and to log informative messages and warnings to the
user.
Incasethegeocodingprocessfails,youreturna NULL geometrytotheuserwitha
warning message, using a try..except Python block.
Search WWH ::




Custom Search