-->

Is it possible to get cities polygonal boundaries

2020-04-14 06:44发布

问题:

I would like to have the possibility to tell if a GPS location is in an inhabited or uninhabited zone.

I have tried some reverse geocoding services out there, but all of them proved useless, because they select the nearest address possible. (I understand why this should be so, it is useful for the purpose of reverse geocoding)

I have noticed in Google Maps, when I search for a city, their boundaries are selected in red dotted well defined line. I would love it to use this, or something similar.

Is there any possible way that Google maps can provide such a service, or something that can solve my problem.

Are there any other web solution or databases that you know of that can give me this information ?

Or maybe I can use any of the reverse geocoding solutions with some parameters (such as restricting the size of searching) to determine if the location is or is not in a populated area?

回答1:

If you will not find a public service then it gets interesting, and expensive in terms of developping effort.

Public data (world wide) is only available from OpenStreetMap, i think they have such a layer (could be named Land_use (rural, etc.)) This layer is usually used to color a map, look at openstreet map Web page if you find a suitable coloring, that coresponds to your task. (E.g look at green, or gray).

These data are stored in polygons, you would have top extract these polygons (i asume millions of them). Ten you need a fast searching spatial index, like a region Quadtree.

Then you do a "point(lat, lon) in polygon" call, and get the polygon related to your position.

Probaly not all that polygons will fit into main memory, so you must load them on demand (e.g by country).

A variant of this approach is to use a geo spatial database like postgres to store that polygons, and do a DB query.

With that approach most work will be extracting the polygons from OpenStreetMap DB file.

More acurate is data from TomTom, but these can be really expensive.