Is anyone having an idea about how to get attribute data of a polygon layer by giving Coordinates with in that polygon. Here i have tried with these codes..
SELECT * FROM kar_bbmp_198 WHERE ST_Contains(geom, ST_GeomFromEWKT('SRID=4326;POINT(779322 1440590)'))
SELECT * FROM public.kar_bbmp_198 WHERE ST_Within(geom,ST_PointFromText('POINT(779322 1440590)',32643));
But I am getting an error message like
ERROR: Operation on mixed SRID geometries ********** Error ********** ERROR: Operation on mixed SRID geometries SQL state: XX000
Any idea... I am using PostGIS 2.0 and PostgreSQL 9.1
Answer
Based on the point-pair values I'll assume the coordinates are meant to be projected in EPSG:32643. Given your error message I'll assume your stored geometry is EPSG:4326. You can transform the point projection, like:
SELECT * FROM kar_bbmp_198
WHERE ST_Within
(
ST_Transform(ST_GeomFromText('POINT(779322 1440590)',32643),4326), geom
) = TRUE;
You might check out the docs for ST_PointFromText, ST_GeomFromText, ST_Contains, and ST_Within for future reference.
Great Article it its really informative and innovative keep here: with new updates.
ReplyDeleteIts was really valuable. Thanks a lot.polygon