Domanda

i have a JSON file that contains lon and lat coordinates. I want to parse this file and then create a new JSON file that contains only coordinates of a certain country.

Is it possible to do this? How to figure out what country the coordinates belong to?

È stato utile?

Soluzione

In broad strokes, it sounds like you want to do what's called reverse geocoding. This is the process of taking a known set of coordinates and getting an address from it. The address would include the country.

Depending on the size of your data set, Google offers one that might suit you. You could write a routine to iterate your data set, reverse geocode each set of coordinates, and get a structured address (including country), which you could cache for future use. With the countries, you could then filter the list down to the specific country you're looking for.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top