1

I have a Point geometry and several Polygons surrounding the point geometry. If I use the ST_DWithin() function and give it, lets say - 500m as a parameter. What Polygons return true? The Polygons that would intersect with a 500m buffer around the point geometry. Or the polygons that have their centroid within the 500m buffer of the point geometry? Or the polygons that are completly within the 500m radius of the point geometry? I hope you understand what I am aiming at.

7
  • Alternative "intersect with a 500m buffer around the point geometry", just like ST_Distance works. But interesting that I could not easily find where it is explained.
    – user30184
    Sep 1 at 11:39
  • @user30184 Yes I did not find any information on this. Thats why I asked here!
    – Stophface
    Sep 1 at 12:07
  • Those polygons that have any point set or ring segment (vector) distance of equal or less than 500m to the point, or have the point intersect its interior.
    – geozelot
    Sep 1 at 12:07
  • The latter condition feels unnecessary. If the point intersects the interior of the polygon (thus, is within), the distance=0.
    – user30184
    Sep 1 at 12:34
  • 1
    @user30184 I was referring to how this is projected in low-level vector math, where it is necessary to determine if the point is inside the polygon first, in order to then declare it to be at distance = 0. The high level definition you stated is correct, of course.
    – geozelot
    Sep 1 at 14:58
1

In the OpenGIS Filter Encoding Implementation Specification http://docs.opengeospatial.org/is/09-026r2/09-026r2.html DWithin is defined this way:

The spatial operators DWithin and Beyond test whether the value of a geometric property is within or beyond a specified distance of the specified literal geometric value. Distance values are expressed using the <Distance> element. The content of the <Distance> element represents the magnitude of the distance and the units attribute is used to specify the units of measure.

I found a nice description from https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/SQLReferenceManual/Functions/Geospatial/STV_DWithin.htm?

Determines if the shortest distance from the boundary of one spatial object to the boundary of another object is within a specified distance.

EDIT Unfortunately I think that this description that considers only boundaries is wrong if one object is within another object.

It is to be noted that the distance from a polygon to a point that is inside the polygon is always zero.

enter image description here

This returns 0

select ST_Distance(
ST_GeomFromText('POLYGON ((3 21, 4 20, 2 20, 3 21))'),
ST_GeomFromText('POINT (3 20.5)'));

But this returns 0.35355

select ST_Distance(ST_Boundary(
ST_GeomFromText('POLYGON ((3 21, 4 20, 2 20, 3 21))')),
ST_GeomFromText('POINT (3 20.5)'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.