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

Paragon Corporation lr at pcorp.us
Mon Feb 2 10:58:59 PST 2015


What is the spatial reference system of your data.  If it’s in degrees, your areas are all going to be all < 1.  You’d have to go with something like 0.0001 or cast your data to geography when you do the check

 

e.g. assuming your srid is 4326 

 

select ST_Asgeojson( geom ) from table where ST_Intersects(ST_GeomFromGeoJSON('$state'), geom)=TRUE and ST_Area(ST_Intersection(ST_GeomFromGeoJSON('$state')::geography, geom::geography))>1

 

Hope that helps,

 

Regina

http://www.postgis.us

http://postgis.net

 

 

 

From: postgis-users-bounces at lists.osgeo.org [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Joseph Spenner
Sent: Monday, February 02, 2015 1:31 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Possible for ST_Intersects to not include the perimeter?

 

Chris:

  I've been trying to get your suggestion to work as well, but appear to be having some problem with the syntax.

 

I currently have a situation where I have a polygon completely inside of a state, as well as a couple on the border.

I have a query, but it returns ZERO:

 

select ST_Asgeojson( geom ) from table where ST_Intersects(ST_GeomFromGeoJSON('$state'), geom)=TRUE and ST_Area(ST_Intersection(ST_GeomFromGeoJSON('$state'), geom))>1

 

 

I have been using the following, with pretty good success:

 

select ST_Asgeojson( geom ) from table where ST_Intersects(ST_GeomFromGeoJSON('$state'), geom)=TRUE and ST_Touches(ST_GeomFromGeoJSON('$state'), geom)=FALSE

 

But sometimes, there seems to be a really tiny square centimeter of area which makes the above succeed, so I would like to have at least some value to describe "how much intersection?" there is.   But even using a small value (1), it always makes my select return no rows.

 

Ideas?


Thanks!

 

Regardds,

Joseph Spenner

 

 

 

  _____  

From: Christopher Swingley <cswingle at swingleydev.com <mailto:cswingle at swingleydev.com> >
To: Joseph Spenner <joseph85750 at yahoo.com <mailto:joseph85750 at yahoo.com> > 
Cc: PostGIS Users Discussion <postgis-users at lists.osgeo.org <mailto:postgis-users at lists.osgeo.org> > 
Sent: Wednesday, January 21, 2015 4:58 PM
Subject: Re: [postgis-users] Possible for ST_Intersects to not include the perimeter?


Joseph,

On Wed, Jan 21, 2015 at 2:34 PM, Joseph Spenner <joseph85750 at yahoo.com <mailto:joseph85750 at yahoo.com> > wrote:

 


>  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.



What about finding the states that intersect thunderstorm warnings
where the intersection area is greater than some small threshold?
Something like:

ST_Intersects(warning_geom, state_geom) AND
ST_Area(ST_Intersection(warning_geom, state_geom)) > 1000

Cheers,

Chris
-- 
Christopher Swingley
Fairbanks, Alaska
http://swingleydev.com/
cswingle at swingleydev.com <mailto:cswingle at swingleydev.com> 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150202/54208de9/attachment.html>


More information about the postgis-users mailing list