Marking population on a map without latitude and longitude coordinates?

Hi I have a map of the UK and I’m trying to load data onto the map but the data file hasn’t got latitude or longitude coordinates for each place to enable me to get the precise location. Is there any way to do this another way?

Hi! Welcome to the forum!

I haven’t tested it but I guess you need to use some kind of API provided online. What about this one?
https://nominatim.org/release-docs/develop/api/Search/

also it depends on the size of the data… if it’s < 10 cities I would manually search the coordinates, but if it’s more then I will automate lookup by a service like above.

1 Like

example:

void setup() {
  String[] cities = {"montreal", "toronto", "ottawa", "gatineau"};
  for(String city: cities) {
    JSONArray j = loadJSONArray("https://nominatim.openstreetmap.org/search?city=" + city + "&format=jsonv2");
    JSONObject o = j.getJSONObject(0);
    println(city, o.getFloat("lat"), o.getFloat("lon"));
  }
}

** note that it’s not so fast to load one by one, so if you are planning to reload the program often and the city list won’t change, I recommend you to make the list of lon/lat first, append that to the data so that you don’t have to make query every time.