Skip to main content
Question

SpatialRelator understanding behavior


olivierl
Contributor
Forum|alt.badge.img+3

Hello,

Using SpatialRelator, I want to test if a feature line from Requestor, is "Requestor is OGC-Within Supplier", where supplier is an other layer line.

If end vertex of line are the same, the test works but otherwise doesn’t work.

OK

NOK 

 

 

6 replies

s.jager
Influencer
Forum|alt.badge.img+16
  • Influencer
  • February 7, 2025

I think you don’t want to test for OGC Within, but OGC Overlaps. A line that has the same vertex at one end, but not at the other end, even if the other vertex is on the line, is not Within that other line. And from what I can make out from your screenshots, that is what you have.

With lines, the endpoints are considered the Boundary, everything in between is Interior. OGC Within tests whether the Interior and the Boundary of the first line are on the Interior of the second line - and that is not the case it looks like.

The documentation explains all of this very well, the PostGIS Introduction workshop describes it quite well as well (little less technical). That might help you getting the results you expect.


olivierl
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • February 8, 2025

thanks for answer

Unfortunatly, overlaps doesn’t work as well.

I tested ‘overlaps’ ogc in that case  and fails again :

 


olivierl
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • February 8, 2025

And Within shoud work because i am in this case :

 


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • February 10, 2025

The limitation with SpatialRelator is that FME works with very high precision accuracy to test if spatially one object is related to another object in a particular way.

In order for two lines to have a WITHIN or CONTAINS relationship, they need to have a very, very high precision. So precise that it can be impossible in some situations to actually test the raw input GIS/spatial data lines actually meet the rules for CONTAINS or WITHIN if the y/x gradient value of the line segments are anything other than 0 or Infinity.  This is because the GIS data storage often uses coordinate accuracy several orders of magnitude less than what FME does.

In order to properly test it, requires first an AnchoredSnapper or Snapper that are set to insert extra vertices into the original lines before using a SpatialRelator Contains or Within test.  As an alternative to SpatialRelator, use a LineOnLineOverlayer  that will allow a user input tolerance for the precision, and the degree of overlap can be tested and this Transformer is also useful for outputting cleansed networks/lines.

Additionally the language in the FME documentation is a little nuanced
 


It is a little more accurate instead say for lines:  “Within” is where the Base End Points and all of the Line intersects the Candidate Line. ie. No part of the Base Interior falls outside the Candidate Line.

In the second post, the spatial relationship shown is INTERSECTS = TRUE, and CROSSES = TRUE, but WITHIN = FALSE since there some of the Interior of the Base Line does not coincide with the Candidate line.

Whilst slightly different implementations of the OGC ISO Standard, the PostGIS documentation gives an alternative definition that may be a little clearer.
https://postgis.net/docs/ST_Within.html


olivierl
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • February 15, 2025

Thanks for this fully answer.

I understood the problem of extra vertice. To solve my problem, I built my own transformer. 

First i test if my base is a straight line with angular transformer, then i extract the first and last coordonate of the line, then vertexCreator of two points, then neighborfinder for both point is true with very small dustance to candidate line.

What a mess to test a basic thing 


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • February 15, 2025

That does sound unnecessarily complicated.  If you can post an example of 2 lines with a geometry that have a Within relationship in a data file, we can probably show how to do it somewhat more easily.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings