I have a shapefile created from ArcMap that contains about 400 geometry's. I've added this shapefile into PostGIS using the shp2pgsql tool. I am trying to use the ST_Intersects function to determine if a given point, using Lat and Long, is within one of the 400 geometry's.
I have a point that I know to be within one of the shapes, but ST_Intersects is returning false for this. The record where cocnum equals "MA-500" contains the point Lat: 42.3581, Long: -71.0636.
SELECT
cocname,
cocnum,
geom,
st_intersects(geom, point(-71.0636,42.3581)::geometry)
FROM
public.coc
WHERE cocnum like 'MA-500'
However, I get the following result:
When I create a KML of the geometry using st_asKml(geom)
and then insert that into google maps, along with the point google.maps.LatLng(42.3581, -71.0636)
I get the following result:
Any ideas on why ST_Intersects is returning false for this?
Best Answer
You need to project your point into your polygon's CRS. You can use ST_Transform to do this.
Specifically you're not intersecting because your polygons projection is in meters, so without re-projecting -71.06, 42.35 in meters is a point not far from the equator and prime meridian.