[postgis-users] ST_Intersects differing results

Timothy Asquith tim at redronin.io
Tue May 24 06:45:00 PDT 2016

I have a table of land parcels in my PostGIS database, and I'm doing a basic spatial join against zoning polygons.

I'm having issues where a previously-correct query is now returning different results.

Up until now, I've been using a Geoserver WFS, and making these queries using CQL's INTERSECT operation. This operation generates a PostGIS query like so:

SELECT * FROM "public"."planning_zones" WHERE "geom" && ST_GeomFromWKB($1, 4326) AND ST_Intersects("geom", ST_GeomFromWKB($2, 4326)) LIMIT 1000000

As my land parcel dataset is snapped to my zoning polygons, this query causes Geoserver to return a single record.

Now, I'm refactoring that query into a JSON API I'm building, and I'm recreating that PostGIS query, and making the query directly to Postgres (not Geoserver).

The problem is that the query is now returning multiple zoning polygons. The difference is that I'm directly joining the zoning polys to the parcels:

SELECT * FROM zones AS z, parcels AS p ON ST_Intersects(z.geom, p.geom) WHERE p.id = 99 AND z.geom && p.geom

This new query is returning multiple results, including polygons that share a boundary. This didn't happen before.

Can anyone shed any light on why this might be happening? My suspicions are that the tolerance of the Geoserver query differs to the raw PostGIS query, but I'm uncertain how to best affect this.

Timothy Asquith // Red Ronin
tim at redronin.io
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20160524/c9e745a0/attachment.html>

More information about the postgis-users mailing list