English translation of the article by Joaquin del Cerro.
Hi, I ‘m here again.
This time to speak about a very quick scripting .
A few days ago Oscar Martinez told me that he had seen a python library to access geocoding services , GeoPy ; but there was the problem that he was unable to use it in gvSIG … as it was designed for a newer python version than the one used in gvSIG.
While we were glancing , we realised that by changing few small things, it could become usable for the python version of gvSIG 2.1.0 .
located in user home. If you have already executed gvSIG, it should be closed and restart .
In Linux you can find this folder in $ HOME , and for Windows in :
C: \ Document and Settings \ my_user
C: \ Users \ my_user
Once installed the library GeoPy it can be used quite simply. If you execute the gvSIG scripts “Composer” , and create a new one with the following code , then you can start testing without any problems.
from gvsig import * from commonsdialog import * from geopy.geocoders import get_geocoder_for_service def main(*args): street = inputbox("Insert street","street") if street == None: return geolocator = get_geocoder_for_service("googlev3") location = geolocator().geocode(street) print(location.address) print((location.latitude, location.longitude)) msgbox("Found:\n"+location.address+"\n"+str((location.latitude, location.longitude)))
You can perform more complex actions such as open a table containing street names and civic addressing, read them and go creating a shapefile with points provided by geolocalisation service, but for the moment you can go on playing with this.
Greetings to all