Skip to main content
Solved

Is there a way to select polygons that have their centroid in another polygon, similar to the way it's done in ArcGIS?


Forum|alt.badge.img

The question is pretty self-explanatory, there is a select by location option in ArcMap that allows you to select polygons from a dataset that have their centroid in polygons from ANOTHER DATASET. I think one would need to use the CenterPointReplacer transformer to create centroids of the polygon and select the centroids that are within the other polygon then join (DatabaseJoiner?) the selection back to the original polygon but I would like to know if there is an easier way.

Best answer by krenty

Thanks for all your help @erik_jan and @jdh. I have since modified my workflow to include the GeometryExtractor and Replacer (this was the key actually) so that I could run my selection of centroids derived from the original polygons and then turn those selected points back into their corresponding polygons. Here is what I did if anyone needs to do something similar.

selectpolygons-that-havecentroids-in-another-polyg.png

Thanks again! :)

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

14 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • May 3, 2018

You could try this:

So from the polygons, replace all by its center point.

Load both polygons and center points to a PointOnAreaOverlayer.

Test the points for more than 1 overlap.


Forum|alt.badge.img
  • Author
  • May 3, 2018
erik_jan wrote:

You could try this:

So from the polygons, replace all by its center point.

Load both polygons and center points to a PointOnAreaOverlayer.

Test the points for more than 1 overlap.

This looks like what I have already, the exception is, for PointOnAreaOverlayer Transformer the Area is coming from another reader polygon (Polygon2) because I need to find out if the centroids from polygons from one feature class (Polygon1) is inside a different polygon(Polygon2), not the one I originally created the centroids from. The thing this doesn't take into account is that I don't actually want the centroids for my end product, I want to have the polygons that have their centroid inside Polygon2 selected. The method above creates the centroids but doesn't link them back to the polygons they were derived from.

 

 


Forum|alt.badge.img
  • Author
  • May 3, 2018
erik_jan wrote:

You could try this:

So from the polygons, replace all by its center point.

Load both polygons and center points to a PointOnAreaOverlayer.

Test the points for more than 1 overlap.

I didn't notice that you chose the CenterLineReplacer transformer, is that intentional?

 

 


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • May 3, 2018
krenty wrote:
I didn't notice that you chose the CenterLineReplacer transformer, is that intentional?

 

 

No, that is a mistake. Should be the CenterPointReplacer.

 

 


Forum|alt.badge.img
  • Author
  • May 3, 2018
erik_jan wrote:

You could try this:

So from the polygons, replace all by its center point.

Load both polygons and center points to a PointOnAreaOverlayer.

Test the points for more than 1 overlap.

Ok, after looking at yours and rethinking a bit, here is what I have constructed:

selectarkypolygons-that-havecentroids-inside-green.png

You can see that there has been ONE more polygon selected when I apply the second PointOnAreaOverlayer to extract the polygons matching the selected centroids. The problem with using the PointOnAreaOverlayer transformer for the polygon re-selection is that it may (I have to check my outputs) be selecting more polygons than necessary because a centroid of one polygon may overlap a polygon that shouldn't be selected(doesn't have centroid in). This is why I would rather create a join between the centroid selection and the original Arky_Polys by a Unique_ID field and then create a polygon output from that selection but I can't find one that can join and select properly. How can I select the Arky_Polys that match the attributes from the centroid selection?


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • May 3, 2018

I would use a Counter (ID)-> GeometryExtractor -> CenterPointReplacer -> SpatialRelator (attributes that must differ the ID from the counter) -> GeometryReplacer.


Forum|alt.badge.img
  • Author
  • May 3, 2018
jdh wrote:

I would use a Counter (ID)-> GeometryExtractor -> CenterPointReplacer -> SpatialRelator (attributes that must differ the ID from the counter) -> GeometryReplacer.

If there is already an attribute that is a UniqueID do I need to have the counter transformer? What am I using the GeometryExtractor Transformer for?

 

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • May 3, 2018
krenty wrote:
If there is already an attribute that is a UniqueID do I need to have the counter transformer? What am I using the GeometryExtractor Transformer for?

 

 

No you do not.

 

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • May 3, 2018
jdh wrote:
No you do not.

 

 

The generate list on the SpatialRelator is also optional (if you want to know *which* polygons the centroid fall inside).

 

 


Forum|alt.badge.img
  • Author
  • May 3, 2018
jdh wrote:

I would use a Counter (ID)-> GeometryExtractor -> CenterPointReplacer -> SpatialRelator (attributes that must differ the ID from the counter) -> GeometryReplacer.

I think the issue here is the same as the other answer, I'm not trying to find the polygons that have their centroids in another polygon from the same dataset but from a different dataset entirely.

 

 


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • May 3, 2018
krenty wrote:

Ok, after looking at yours and rethinking a bit, here is what I have constructed:

selectarkypolygons-that-havecentroids-inside-green.png

You can see that there has been ONE more polygon selected when I apply the second PointOnAreaOverlayer to extract the polygons matching the selected centroids. The problem with using the PointOnAreaOverlayer transformer for the polygon re-selection is that it may (I have to check my outputs) be selecting more polygons than necessary because a centroid of one polygon may overlap a polygon that shouldn't be selected(doesn't have centroid in). This is why I would rather create a join between the centroid selection and the original Arky_Polys by a Unique_ID field and then create a polygon output from that selection but I can't find one that can join and select properly. How can I select the Arky_Polys that match the attributes from the centroid selection?

This is where @jdh is using the GeometryExtractor (saves the geometry definition in an attribute) and GeometryReplacer (gets the saved geometry definition from the attribute and re-creates the geometry, in your case the original polygon).

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • May 3, 2018
krenty wrote:
I think the issue here is the same as the other answer, I'm not trying to find the polygons that have their centroids in another polygon from the same dataset but from a different dataset entirely.

 

 

Then just have the Supplier port of the SpatialRelator coming from the other dataset.

 

 

If there are no identical polygons between the datasets, you can ignore the setting "attributes that must differ"

Forum|alt.badge.img
  • Author
  • May 3, 2018
erik_jan wrote:
This is where @jdh is using the GeometryExtractor (saves the geometry definition in an attribute) and GeometryReplacer (gets the saved geometry definition from the attribute and re-creates the geometry, in your case the original polygon).

 

That makes sense, I think I get what you guys are saying.

 

 


Forum|alt.badge.img
  • Author
  • Best Answer
  • May 3, 2018

Thanks for all your help @erik_jan and @jdh. I have since modified my workflow to include the GeometryExtractor and Replacer (this was the key actually) so that I could run my selection of centroids derived from the original polygons and then turn those selected points back into their corresponding polygons. Here is what I did if anyone needs to do something similar.

selectpolygons-that-havecentroids-in-another-polyg.png

Thanks again! :)


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