Alexandru Chirila
Alexandru Chirila

Reputation: 2352

Determine if GPS location is within city limits?

I want to be able to determine if a GPS location is in an inhabited or uninhabited zone.

I have tried several reverse geocoding API like Nominatim, but failed to get good results. It always returns the nearest possible address, even when I selected a location in the middle of a forest.

Is there any way to determine this with reasonable accuracy? Are there any databases or web services for this ?

Upvotes: 2

Views: 1680

Answers (2)

AlexWien
AlexWien

Reputation: 28727

If you have to calculate that youself, then the interesting things start:

The information whether or not a region is inhabited is stored in digital maps in layer "Land_Use". There are values for Forest, Water, Industry, Cemetary, etc.

You would have to import these Land_use polygons into a special DB (PostGres). Such a spatial DB provides fast geo indizeds for searching only the relevant polygons.

Some countries may also fit in main memory, but then you need some kind of geo spatial index, like Quad-Tree or k-d tree to store the polygons.

Once you have imported the polygons, it is a simple "point in polygon" query, or "polygons within radius r". The typoe of th epolygon denotes the land use.

OpenStreetMap provides these polygons for free.

Otherwise you have to buy them from TomTom or probably NavTeq (Nokia Maps). But this makes only sense for major companies.

Upvotes: 1

Joachim Isaksson
Joachim Isaksson

Reputation: 180897

Since you're using Nominatim, you're getting the coordinates of the nearest address back in the reply.

Since the distance between two coordinates can be calculated, you can just use that to calculate the distance to the closest address found, and from that figure out if you're close to populated areas or not.

Upvotes: 1

Related Questions