[GIS] Android GIS – Reverse Geocode using Shapefile (.shp)

androidMySQLreverse-geocodingshapefile

I want to develop an Android application. I'm still a newbie here.

What I want is to develop my app just like a GIS that can implement reverse geocoding. So I can put in lat / lon coordinates and then text is returned, for example the city name.

But I don't want to implement Reverse Geocode using Geocoder from Google, all I want is for the coordinates that I entered to be checked from a shapefile (.shp) in the database, then return a city name. And I want to use MySQL as a database for my shapefile (shp). Is it possible, and what should I do to make it happen? Could you give a tutorial?

Thanks in advance.

Best Answer

Seeing as it's Android, you might be far better using something like Spatialite, which has an active project building on Android. Spatialite can store all your city point co-ordinates (and even your city boundaries)

So long as you don't need absolute pinpoint accuracy, then a possible approach is to find the nearest "city point" to your point (the more city points you have the more accurate it will be). This is fairly easy to do in Spatialite, and is very quick if you use an index. This is what is known as "reverse geocoding" not your approach comparing a point to an entire shape, as Uffe has pointed out. It would be possible to return which city polygon a point is within in Spatialite, but this would take far longer, and may be too slow for the Android platform, depending on your dataset size.

If you are doing all this on a server, not the device, then obviously your options are much greater and you can use many other solutions, although I would say PostGIS could be the most effective.