Points within polygons in different projections
Some software will use great circle arcs to connect unprojected vertices (sometimes when using a special data type, like PostGIS geography
), while projected (or unprojected using the geometry
datatype) vertices are connected using straight lines.
This can result in a point being inside a polygon expressed as geography
but outside of it if expressed as geometry
The following example uses PostGIS. The polygon goes up to latitude 50, the point is at latitude 51.
WITH poly AS (select ST_GeomFromText('polygon((0 0, 50 0, 50 50, 0 50, 0 0))',4326) as geom),
pnt AS (select ST_GeomFromText('point(25 51)',4326) as geom)
SELECT ST_INTERSECTS(poly.geom,pnt.geom) intersect_geometry,
ST_INTERSECTS(poly.geom::geography,pnt.geom::geography) intersect_geography
FROM poly, pnt;
intersect_geometry | intersect_geography
--------------------+---------------------
f | t
Edit
Extending on @JR comment, here is an example when projecting a huge polygon to a Lambert Conformal Conic projection (3347) and checking the point intersection near the central meridian: we can see a difference of 4 degrees of latitude between the two!
WITH poly AS (select ST_GeomFromText('polygon((-70 45, -130 45, -130 50, -70 50, -70 45))',4326) as geom),
pnt AS (select ST_GeomFromText('point(-100 54)',4326) as geom)
SELECT ST_INTERSECTS(poly.geom,pnt.geom) intersect_geometry,
ST_INTERSECTS(st_transform(poly.geom,3347),st_transform(pnt.geom,3347)) intersect_reproject
FROM poly, pnt;
intersect_geometry | intersect_reproject
--------------------+---------------------
f | t
Yes. projections will never reproject a point that was inside a polygon in one projection to be outside it in another--unless there's some sort of precision error. I'm not sure what this property is called in geography, but I just realized it's essentially relativistic invariance, which basically says that as time dilates for us, and our coordinate systems are compressed or stretched, no observer in any given frame will disagree on causal ordering of events. Likewise, no matter in what projection an "observer lives", no one will disagree on what points are in what polygons, even if they disagree on exactly how far the points are from the edges of the polygons, and stuff like that.