1

I want to geocode a set of addresses with GoogleMaps, store the results in a different SRID in a PostGIS table and then project it in QGIS over a layer with the identical SRID. So far, it has been a complete mess since I succeed in geocoding but can't change the SRID so I can't have overlapping layers.

I break the process in steps:

  1. Geocode addresses
  2. Add column mygeometry with a different SRID (2100) than the geocoder's usual (GoogleMaps' Mercator) and store it all at my PostGIS table as tableA
  3. Open QGIS, add layers from tableA and tableB (which is a map of the country).

Here's the Python code for geocoding and storing (I note that mygeometry column has already been created as a geometry(MultiPoint,2100) column:

from geopy import geocoders    
g = geocoders.GoogleV3()    
for i in range (1,tableAlength):
    location, (latitude, longitude) = g.geocode(tableA.ix[i][1])
    if location:
        mygeometry ='SRID=2100;MULTIPOINT(%r %r)' % (longitude, latitude)
        mystring=("UPDATE tableA SET latitude="
                  +str(latitude) +" WHERE tableA_id='"+str(i)+"';")
        db.alters(mystring)
        mystring=("UPDATE tableA SET longitude="
                  +str(longitude) +" WHERE tableA_id='"+str(i)+"';")
        db.alters(mystring)
        mystring=("UPDATE tableA SET mygeometry='"
                  +str(mygeometry)+"' WHERE tableA_id='"+str(i)+"';")
        db.alters(mystring)
        i=i+1
    else:
        i=i+1

I have tried it also with Nominatim and no success. The question is why it does not store my points in the new SRID.

  • 1
    I edited my post in order to set one specific question. Im taking the tour now and not before since I thought its the same philosophy as in the rest stackoverflow. Thx for your comment. The SRID issue has really troubled me. – lios Jan 20 '16 at 21:52
  • Note that you are generally not allowed to use google geocoding except for with google maps: developers.google.com/maps/terms#section_10. – BradHards Jan 21 '16 at 10:13
  • I see. Good to know. Thank you very much for the heads-up. – lios Jan 21 '16 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.