I try to do Reverse Geocode from my shapefile on the database. I'd already try with Spatialite and PostGIS to put shapefile (.shp) into it. But I'm still can't delivered my objection about reverse geocode from my shapefile on the database. My shapefile (.shp) is content with district polygon, all I want is simple: Pass some coordinate, and check that coordinate is in what district polygon from shapefile, then return the district name. That's all. Does anybody know the SQL Query to do that reverse geocode in PostGIS or Spatialite?

Thanks before. :(


Suppose your district table looks like this

districts(name text, the_geom geometry)

Then you would select the district a point falls into using

SELECT name 
FROM districts
WHERE ST_Within(ST_SetSRID(ST_MakePoint(lon,lat),4326),

Replace lon and lat with your values.

If your districts are in a different projection than WGS84, use ST_Transform.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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