Sunday, 17 November 2019

google maps - How to Geocode a City


I know that I can just call one of any number of geocoding APIs to perform this for me. This is more of a curiosity than anything else.


With that aside, how does someone (like Google) turn a city name into a latitude and longitude? From playing around with Google Maps it appears that most of the time a city is pinpointed to it's downtown area, but there seems to be no reason why one street corner is picked over any other street corner.


I am just curious what algorithm a geocoding service provider would utilize for performing such an action?



Answer



The label placement is often designed to improving map readability rather than being driven by the data directly: often cartographic displacement is performed on the original geometries to improve the legibility of the map. 41Latitude had a great article on city label placement you might be interested in.



The USGS GeoNames aka GNIS (a commonly used public domain gazetteer used by e.g. Geonames.org, Wikipedia, OpenStreetMap) provides this note:



...The guideline for digitizing areal features requires that the primary coordinates be taken in the center, but the location of the center of a large city is sometimes somewhat subjective.



If you were looking to algorithmically choose the center of a city you might use the centroid of a polygon delineating the city limits, or perhaps something more sophisticated like using the center of the alpha shape.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...