3

I've got about 300,000 lat/lng coordinates of events that I'm combining into a large map. The coordinates come from all over the world.

For each point, I want to find the nearest city of at least XYZ residents. I've written a Node script that uses the geoNames database of world cities and does all the calculations.

It all works fine but for the fact that there seems to be a far amount of overlap in some of these cities. For example, cities15000.txt lists both "North Atlanta" and "Atlanta," and there is both a "Manhattan" and a "New York City."

I was hoping I could limit the search to the highest level in the city hierarchy using geoNames' feature codes, but the documentation is not terribly clear. North Atlanta is "PPL" (populated place), Atlanta is PPLA (seat of a first-order administrative division). I thought I could limit to PPLA, but Baltimore is PPLA2 (seat of a second-order administrative division). There does not appear to be anything near Baltimore (say, "City of Baltimore" or something) that I'm missing.

Where do these codes come from? Is there a way to eliminate subsections of cities? I also don't mind using a different source, though I do find the geoNames data clean and easy to manipulate.

1 Answer 1

5
+50

Working with the GeoNames.org database can be a bit difficult because of this inconsistency in the categories you described. I don't know where it comes from, but I guess it has to do with the different sources the names are from. In regions like Europe it is even harder to work with the GeoNames.org data, because of the different administration levels in different countries. Additionally the coordinates of the places are not exact everywhere. Especially in rural areas and bigger scales there is some kind of systematical error where the coordinates for the names seem to be set on a grid.

The points in the yellow boxes show the strange pattern, the arrow shows, which town the point is standing for

The points are the names from Geonames.org. The yellow boxes show the strange pattern of the names. The arrow shows the coordinate error for this particular name

Maybe you want to try to work with OpenStreeMap Data. They have well described codes (map features) for Places where often the population has been added. From my own experience I can tell, that the coordinates for those places are exact and the population numbers, too.

To get the data you could download data extracts from Geofabrik or you could try the Overpass API. There you could download the required data to work with it offline or you use the api on the fly with queries like this. The only downside of those queries is, that at the moment (for what I know) you cannot do numeric comparisons - it is still on the wishlist

1
  • Glad I could help!
    – bennos
    Mar 19, 2014 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.