Question

Transformer for Selecting features having centroid inside polygon

  • 8 February 2016
  • 6 replies
  • 23 views

Badge

Hi,

I a searching alternate transformers to Clip process, because its slow sometimes. Tried LineOnAreaOverlayer, but its using complete resources of system and become unresponsive. Is there any spatial selection transformer available similar to ArcGIS spatial selection like "Select features having centroid inside polygon" ? After LineOnAreaOverlayer, i simply use this option and load selected features into target database.


6 replies

Userlevel 2
Badge +12

To create a centroid in FME 3 transformers are available:

CenterPointReplacer (creates a point on the intersection of the diagonals of the bounding box. Does not have to be inside the polygon), InsidePointReplacer (creates a point inside the polygon. Usually the centerpoint) and CenterofGravityReplacer. As I see now, these 3 have been merged into the CenterPointReplacer in FME 2016 (with the 3 options in a parameter).

Badge +22

GeometryExtractor->CenterPointReplacer->SpatialFilter->GeometryReplacer

Extract the original geometry into an attribute

 

Convert the geometry to a point

 

Filter points within polygon

 

Restore original geometry
Badge

Hi Erik_jan, jdh,

Thanks for quick guidance.

I am looking for selecting lines inside a polygon. If i use 'LineOnAreaOverlayer' transformer, it will create nodes wherever lines intersect with polygon boundary. Then i can select only lines having their centroids inside a polygon instead of clip process. I hope this saves time when compared to Clip transformer process.

Userlevel 2
Badge +12

Another option is changing the process:

Read only the polygons into FME.

Then use the FeatureReader to read only those lines, that interact with the polygons.

If the lines are in a database, the database will do the hard work of spatially selecting the set of lines.

Next you could use the Clipper (if needed) to do the clipped selection inside the polygons (but on a smaller amount of lines).

Userlevel 4
Badge +13

I think the key to your situation is to reduce the volume of data piling up in memory. If you're using an Overlayer, all the data gets blocked up until the readers have finished, and then the work begins. And very likely we are in a tight memory situation then.

The first thing I'd try is to go back to the Clipper and ensure that the Clipper is set to "Clippers First". Then make sure that however you a reading the data, that the polygon clippers are read before the things you want to clip. You can use 2 different readers to accomplish this if need be. For fastest performance, do as @erik_jan suggests above (but only if your lines are in a spatial database that supports spatial queries). Read the polygons with a normal reader. Connect them first as Clippers to your clipper, with Clippers First set. Then add a 2nd reader to read the very same polygons and connect these to a FeatureReader to read your lines. Set it up to impose a spatial query. Lastly, route the results from teh FeatureReader into the Clipper. Should be much faster.

Badge +3

How about tiling the proces if you got that many features to compare?

Tile the lines and the polygons with a grid, same grid for both of them. (or Tiler with seed X/Y set to BB of both datasets)

THen do a Spatialrelator with calculate cardinality set to paralell processing group_by rown AND column.

Test for _relationships_cardline >0 and select relevant fme_feature_type

Reply