Skip to main content
Solved

SpatialFilter - strange results?


lambertus
Enthusiast
Forum|alt.badge.img+16

SpatialFilter gives more intersections than expected, any clue?

For a parcel I want to compute the area covered by buildings on that parcel. The start situation, with one parcel and some buildings.
 


My next plan was to use a SpatialRelator to create a list of buildings located at the yellow parcel.

I tested this approach using a SpatialFilter first to see whether the intersect function works. I expected to get back only the 2 red buildings within the parcel polygon. However, I got this:

A subpolygon of one the buildings is also selected. Did I something wrong?
​​​


My settings of the SpatialFilter:


Any ideas how to solve this? I tried other Predicates to test as well but so far no success.

 

Best answer by nielsgerrits

One way to do this:

  • Generate _parcel_id.
  • Calculate _parcel_area.
  • Parcels & buildings into AreaOnAreaOverlayer.
  • Filter where _parcel_id has a value.
  • Filter where _overlaps = 1.
  • Calculate _parcel_area_no_buildings.

For this to work, no overlap is allowed in the parcels. If this is not the case, you will first need to relate buildings to parcels, to merge parcel id’s to buildings to be able to do a group by in the AreaOnAreaCalculator.

Parcels will end up with geometries wit buildings cut from it. To restore the original geometry I use a GeometryExtractor before the geometry is changed to get it to an attribute and a GeometryReplacer to restore the original geometry from this attribute. This way you won’t need a blocking FeatureMerger.

Attached sample workspace.

View original
Did this help you find an answer to your question?

7 replies

nielsgerrits
VIP
Forum|alt.badge.img+54
  • Best Answer
  • June 25, 2024

One way to do this:

  • Generate _parcel_id.
  • Calculate _parcel_area.
  • Parcels & buildings into AreaOnAreaOverlayer.
  • Filter where _parcel_id has a value.
  • Filter where _overlaps = 1.
  • Calculate _parcel_area_no_buildings.

For this to work, no overlap is allowed in the parcels. If this is not the case, you will first need to relate buildings to parcels, to merge parcel id’s to buildings to be able to do a group by in the AreaOnAreaCalculator.

Parcels will end up with geometries wit buildings cut from it. To restore the original geometry I use a GeometryExtractor before the geometry is changed to get it to an attribute and a GeometryReplacer to restore the original geometry from this attribute. This way you won’t need a blocking FeatureMerger.

Attached sample workspace.


lambertus
Enthusiast
Forum|alt.badge.img+16
  • Author
  • Enthusiast
  • June 25, 2024
nielsgerrits wrote:

One way to do this:

  • Generate _parcel_id.
  • Calculate _parcel_area.
  • Parcels & buildings into AreaOnAreaOverlayer.
  • Filter where _parcel_id has a value.
  • Filter where _overlaps = 1.
  • Calculate _parcel_area_no_buildings.

For this to work, no overlap is allowed in the parcels.

Attached sample workspace.

Thanks! Will give it a try. I am still curious why I got these results from the SpatialFilter. Any idea? :)
@nielsgerrits 


nielsgerrits
VIP
Forum|alt.badge.img+54

Hard to say without data, but coordinates in fme are floating point precision, which means the vertices are not snapped on a grid. This probably causes a very tiny intersection between the parcel and the third building.


lambertus
Enthusiast
Forum|alt.badge.img+16
  • Author
  • Enthusiast
  • June 25, 2024

@nielsgerrits thanks for your solution. Works perfect. What would be the solution when I have multiple parcels and different buildings located at all of these parcels?


nielsgerrits
VIP
Forum|alt.badge.img+54
lambertus wrote:

@nielsgerrits thanks for your solution. Works perfect. What would be the solution when I have multiple parcels and different buildings located at all of these parcels?

Not sure I understand what you mean. This approach can be used for multiple parcels and buildings, as long as the parcels are not overlapping.


lambertus
Enthusiast
Forum|alt.badge.img+16
  • Author
  • Enthusiast
  • June 26, 2024
nielsgerrits wrote:
lambertus wrote:

@nielsgerrits thanks for your solution. Works perfect. What would be the solution when I have multiple parcels and different buildings located at all of these parcels?

Not sure I understand what you mean. This approach can be used for multiple parcels and buildings, as long as the parcels are not overlapping.


@nielsgerrits  Your approach was almost fine, thanks for sharing. I only faced a problem in case a parcel was split into different sections because of buildings which cut the parcels into different parts. I solved this using StatisticsCalculator, Sum of area for each parcel id (Group By)  = total area no building for that id


nielsgerrits
VIP
Forum|alt.badge.img+54
lambertus wrote:
nielsgerrits wrote:
lambertus wrote:

@nielsgerrits thanks for your solution. Works perfect. What would be the solution when I have multiple parcels and different buildings located at all of these parcels?

Not sure I understand what you mean. This approach can be used for multiple parcels and buildings, as long as the parcels are not overlapping.


@nielsgerrits  Your approach was almost fine, thanks for sharing. I only faced a problem in case a parcel was split into different sections because of buildings which cut the parcels into different parts. I solved this using StatisticsCalculator, Sum of area for each parcel id (Group By)  = total area no building for that id

An alternative is to use the Aggregator, this will merge the geometry in a aggregate / collection.


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