Tuesday, 29 January 2019

postgis - To get attribute data of polygon layer by giving Lat/Lon


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.


1 comment:

  1. Great Article it its really informative and innovative keep here: with new updates.
    Its was really valuable. Thanks a lot.polygon

    ReplyDelete

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...