Skip to content

Instantly share code, notes, and snippets.

@aaizemberg
Last active May 13, 2021 17:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaizemberg/58e7b4bbf4755ade68e8 to your computer and use it in GitHub Desktop.
Save aaizemberg/58e7b4bbf4755ade68e8 to your computer and use it in GitHub Desktop.
Geocoding OpenRefine (using Google, OSM or USIG)

Google API

https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=caba,%20argentina&key=YOUR_API_KEY

YOUR_API_KEY --> https://developers.google.com/maps/documentation/geocoding/get-api-key

grel:"https://maps.googleapis.com/maps/api/geocode/json?address=" + escape(value,"url") + "&key=YOUR_API_KEY"

donde value podria ser: "Balcarce 50, CABA, Argentina" o "Avellaneda, provincia de Buenos Aires, Argentina"

Luego tomamos el primer resultado:

lat <-- grel:value.parseJson().results[0].geometry.location.lat

lon <-- grel:value.parseJson().results[0].geometry.location.lng

OSM nominatim

http://wiki.openstreetmap.org/wiki/Nominatim

Buscando solo por el nombre del pais.

http://nominatim.openstreetmap.org/search.php?country=Switzerland&format=jsonv2

Buscando una ciudad, dentro de un pais.

http://nominatim.openstreetmap.org/search?format=json&city=Ciudad%20de%20Mexico&country=Mexico

'http://nominatim.openstreetmap.org/search?format=json&country=Mexico&city=' + escape(value, 'url')

[{"place_id":"261365","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright","osm_type":"node","osm_id":"62270270","boundingbox":["19.2725301","19.5925301","-99.2932102","-98.9732102"],"lat":"19.4325301","lon":"-99.1332102","display_name":"Ciudad de México, Cuauhtémoc, Distrito Federal, México","class":"place","type":"city","importance":1.0348074577301,"icon":"http://nominatim.openstreetmap.org/images/mapicons/poi_place_city.p.20.png"}]

https://nominatim.openstreetmap.org/search?format=json&q=R%C3%ADo%20Ceballos,%20C%C3%B3rdoba&limit=1

"https://nominatim.openstreetmap.org/search?format=json&q=" + escape("Río Ceballos, Córdoba",'url') + "&limit=1"

http://nominatim.openstreetmap.org/?format=json&street=Lavarden%20315&city=CABA&country=Argentina&limit=1

"http://nominatim.openstreetmap.org/?format=json&street=" + escape(value,'url') + "&city=CABA&country=Argentina&limit=1"

value.parseJson()[0].lat

value.parseJson()[0].lon

USIG

Web Services USIG

http://servicios.usig.buenosaires.gob.ar/normalizar/?direccion=PEPIRI+758%2C+caba

{
  "direccionesNormalizadas": [
    {
      "altura": 758,
      "cod_calle": 17056,
      "cod_calle_cruce": null,
      "cod_partido": "caba",
      "coordenadas": {
        "srid": 4326,
        "x": "-58.409253",
        "y": "-34.646839"
      },
      "direccion": "PEPIRI 758, CABA",
      "nombre_calle": "PEPIRI",
      "nombre_calle_cruce": "",
      "nombre_localidad": "CABA",
      "nombre_partido": "CABA",
      "tipo": "calle_altura"
    }
  ]
}

GREL

lat <-- value.parseJson().direccionesNormalizadas[0].coordenadas.y
lon <-- value.parseJson().direccionesNormalizadas[0].coordenadas.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment