[postgis-users] Possible for ST_Intersects to not include the perimeter?

Pete Yunker peter.yunker at homejunction.com
Wed Jan 21 14:17:20 PST 2015


I believe you want ST_Contains.  Using sample Census TIGER data for states and counties:

SELECT COUNT(c.*)
FROM prod.states s
INNER JOIN prod.counties c
ON (s.name = 'Georgia'
AND ST_Contains(s.the_geom, c.the_geom));
--159

SELECT COUNT(*) from prod.counties WHERE state_cd = 'GA';
--159

I suppose it's possible that the NWS polygons aren't using the exact same county/boundary border as your reference states boundaries.  As such, you could also use a slight negative buffer on the NWS polygons to further ensure that they don't overlap an adjacent state border.

Regards,
Pete Yunker

On Jan 21, 2015, at 5:01 PM, Joseph Spenner <joseph85750 at yahoo.com> wrote:

> For the record, my best guess (which didn't work) was:
> 
> select ST_Asgeojson( geom ) from polys where ST_Intersects(ST_GeomFromGeoJSON('$jsonPoly'), geom)=TRUE and ST_Touches(ST_GeomFromGeoJSON('$jsonPoly'), geom)=FALSE
> 
> Since 'touch' seemed to be the way to address the perimeter points.  But apparently this is not the case.
> 
> 
> 
> 
> 
> From: Joseph Spenner <joseph85750 at yahoo.com>
> To: "postgis-users at lists.osgeo.org" <postgis-users at lists.osgeo.org> 
> Sent: Wednesday, January 21, 2015 2:22 PM
> Subject: Possible for ST_Intersects to not include the perimeter?
> 
> I have a polygon as an input, and I'm trying to find all polygons which share points, but not the perimiter points themselves.  Is this possible?
> 
> Real application:
>   I have NWS polygons describing Thunderstorm Warnings, which are made up of counties within the state.  Some of those counties might be on the edge of the state.  I want to query my database to show me all Warnings which are in a supplied state.  However, if I query the adjacent state which borders the counties from the first state, I get those Warnings because they share the same parimeter points.
> 
> Is there a way to construct a query which will not return anything if the only points in common are the perimeter values themselves?
> 
> I tried a few variations on ST_Intersects/ST_Covers/ST_Contains/ST_Overlaps, supplying various AND/OR and TRUE/FALSE combinatins, but I can't seem to get the right combo to accomplish my task.
> 
> Any help would be great.
> 
> Thanks!
> 
> Regards,
> Joseph Spenner
> 
> 
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150121/9e5fcc2d/attachment.html>


More information about the postgis-users mailing list