I have a point at (-130.2, 30.5)
and a box at (-130, 30, -129, 31)
. As geometry, the &&
operator reports no bounding box intersection, while as geography, it does:
WITH src(point, envelope) AS (SELECT
ST_SetSRID(ST_MakePoint(-130.2, 30.5), 4326) AS point,
ST_MakeEnvelope(-130.0, 30.0, -129.0, 31.0, 4326) AS envelope)
SELECT
point::GEOMETRY && envelope::GEOMETRY AS geom_bbox_intersects,
point::GEOGRAPHY && envelope::GEOGRAPHY AS geog_bbox_intersects,
ST_Intersects(point::GEOGRAPHY, envelope::GEOGRAPHY) AS geog_poly_intersects
FROM src;
geom_bbox_intersects | geog_bbox_intersects | geog_poly_intersects
----------------------+----------------------+----------------------
f | t | f
Here's what the scenario looks like in 2D (using QGIS in SRID 4326):
I assume for geography, PostGIS is using a rectangular bounding box on the spheroid rather than my longitude-parallel envelope. Is that the case? How might I visualize what's going on in PostGIS using a 2D tool like QGIS?
Versions
- PostgreSQL: 10.17
- PostGIS: 2.4