Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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. :(

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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),
                the_geom);

Replace lon and lat with your values.

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

share|improve this answer
    
SUPER THANKS>>>> :D –  AdityaSetyadi Apr 17 '12 at 7:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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