[GIS] PostGIS query with Lon Lat

postgis

Need SQL syntax for …
I have a table with individual polygons like a jigsaw puzzle.
Given a Lon Lat, I need to find the polygon where the lon lat in located.
I am trying:

select * from "parcels_06003" where "geom" @ ('-120.0077874119654', '38.71168052297362')

geom is my polygon column in the db.

Best Answer

Use for example ST_Within:

SELECT * FROM "parcels_06003"
WHERE ST_Within (ST_PointFromText('POINT(-120.0077874119654 38.71168052297362)', 4326), geom);

You were vague on how you provide lat/lon, so the point construction may need tweaking. The 4326 is the SRID of the WGS84 projection.

Continuing from the comments, your projection is SR-ORG:15, very similar to 4269, so you can try with 4269 first or follow the PostGIS insertion link on the page to add it (if it isn't present already as 915).