0
votes

I'm working on a system that stores latitude/longitude information of addresses in a PostGIS table. To store Lat/Long in geometry data type I'm using ST_GeometryFromText function.

For example the following function call gets the geometric value against the specified Lat/Long position:

 myPointGeo =  ST_GeometryFromText('POINT(40.758871 -73.985114));

Similarly, I convert a Polygon into geometric representation as follows:

myPolygonGeo =  ST_GeometryFromText('POLYGON ((40.7566484549725 -73.9878561496734, 40.7556894646734 -73.9853026866913, 40.7545841705587 -73.9860537052154, 40.7548036054111 -73.9881458282471, 40.7559820394514 -73.9887895584106, 40.7566484549725 -73.9878561496734 ))')

I want to find out whether the above lat/long position resides within this Polygon or not. For this I'm using ST_Within function. But though 'myPointGeo' actually resides within the Polygon, ST_Within is returning false. I'm using ST_Within this way:

 St_Within(myPointGeo,myPolygonGeo)

What am I doing wrong here? Should I use some other function for this purpose?

1

1 Answers

0
votes

The query looks correct. It returns false since the point is not in the polygon. The two geometries are disjoint.

point in polygon