Search code examples
csvleafletdata-visualizationopenstreetmapgeojson

Is there an easy way to collect LatLng coordinates as geojson?


I have a set of information as a csv-file that I want to bind in several pop-ups using Leaflet.js. For that I need to collect hundereds of city-coordinates mentioned in the csv-file.

During my research I found OSM Boundaries what makes collecting geojson-data quite easy. But the problem with OSM boundaries is that it only contains geometry as MultiPolygons.

In my case I'm searching for a single pair LatLng coordinates like from the citycenter or so.

geojson.io is another simple tool to collect geojson. I can search for the cities but need to set a marker on the map by myself. That seems quite uncomfortable to me.

I know that Open Street Map offers all the information I need, I just don't no how to export/collect them properly.

Thanks for any kind of help!


Solution

  • You sound to be looking for geocoding functionality, i.e. finding the lat-lng coordinates of your places by city name.

    Please have a look at Leaflet geocoding plugins. With most of them, you can use them programmatically, instead of manually entering the city name. Check out each one API.

    Note that your result may still need some manual clean up, as geocoding often gives you several matching places.