Solved

How to convert GeometryCollection to MultiPolygon

  • 27 January 2022
  • 8 replies
  • 273 views

I am trying to export to a geojson file (to upload to Mapbox). Unfortunately, 5 out of my 736 features have a type of GeometryCollection. The remainder of the features are MultiPolygon and Polygon. Mapbox is unable to work with the GeometryCollection. I tried using a GeometryCoercer with the Geometry Type set to fme_multi, but all of the features go through the Untouched port. I also tried running the 5 through a GeometryRefiner. This converts 2 of the 5 to MultiPolygon, but I can't seem to get the remaining 3. I have been trying to figure out how to use the GeometryPartExtractor, but I can't seem to get the syntax correct (this is all quite new to me). I'm also wondering if my lack of understanding of the Geometry XQuery syntax is the reason I can't get the GeometryCoercer to work. If anyone has any experience with this, I would greatly appreciate the advice. Thank you.

icon

Best answer by caracadrian 27 January 2022, 06:44

View original

8 replies

Badge +20

Try sending the 5 (3) geometries through Deaggregator, GeometryFilter for Area and then Aggregator to recreate MultiPolygons with GroupBy on a common attribute.

Also, inspect the non area features coming out of GeometryFilter to figure out the cause of the problem.

Try sending the 5 (3) geometries through Deaggregator, GeometryFilter for Area and then Aggregator to recreate MultiPolygons with GroupBy on a common attribute.

Also, inspect the non area features coming out of GeometryFilter to figure out the cause of the problem.

Thanks for the quick response @caracadrian​. Unfortunately, this doesn't work. The odd thing is that when I send the 5 geometries through the GeometryFilter with all geometry types, they all pass through the Area filter. Nothing goes through the Collection filter. When i use the Deaggregator, GeometryFilter for Area and then Aggregator with a group on id, I end up with exactly what I started with. A GeometryCollection that still passes through the Area filter. I'm extremely perplexed as to why these features are getting assembled this way when many others are coming through as Multi-Part.

Badge +20

Thanks for the quick response @caracadrian​. Unfortunately, this doesn't work. The odd thing is that when I send the 5 geometries through the GeometryFilter with all geometry types, they all pass through the Area filter. Nothing goes through the Collection filter. When i use the Deaggregator, GeometryFilter for Area and then Aggregator with a group on id, I end up with exactly what I started with. A GeometryCollection that still passes through the Area filter. I'm extremely perplexed as to why these features are getting assembled this way when many others are coming through as Multi-Part.

Can you send the collections to a FFS Writer and post them here so we can take a look at them.

Maybe there is something you overlooked.

Thanks for the quick response @caracadrian​. Unfortunately, this doesn't work. The odd thing is that when I send the 5 geometries through the GeometryFilter with all geometry types, they all pass through the Area filter. Nothing goes through the Collection filter. When i use the Deaggregator, GeometryFilter for Area and then Aggregator with a group on id, I end up with exactly what I started with. A GeometryCollection that still passes through the Area filter. I'm extremely perplexed as to why these features are getting assembled this way when many others are coming through as Multi-Part.

Here it is. I can't thank you enough for your time @caracadrian​.

Badge +20

Thanks for the sample data.

Deaggregator (Flatten All Levels) followed by Aggregator with GroupBy on geoid resets all the features to MultiArea.

Deaggregator FlattenAllLevelsI have also attached a workspace that can help you figure things out.

Thanks for the sample data.

Deaggregator (Flatten All Levels) followed by Aggregator with GroupBy on geoid resets all the features to MultiArea.

Deaggregator FlattenAllLevelsI have also attached a workspace that can help you figure things out.

Okay, huge face palm. The "all levels" is exactly what I was missing. Do you by chance have any idea why those features were coming through as GeometryCollection in the first place? There are other multi-part features in this dataset, so I'm just not clear as to what is causing the issue in the first place. Again though, thank you very much for your help with this!

Badge +20

Okay, huge face palm. The "all levels" is exactly what I was missing. Do you by chance have any idea why those features were coming through as GeometryCollection in the first place? There are other multi-part features in this dataset, so I'm just not clear as to what is causing the issue in the first place. Again though, thank you very much for your help with this!

I know the facepalm feeling 😁.

I managed to create some myself a few times. They are the result of multiple aggregations. As in you create a multipolygon and then you add another polygon or multipolygon to it to get a bigger feature. That is why Refiner works on some of them, as it dissolves multiparts.

Some applications treat them as multi areas and others as aggregates.

Okay, huge face palm. The "all levels" is exactly what I was missing. Do you by chance have any idea why those features were coming through as GeometryCollection in the first place? There are other multi-part features in this dataset, so I'm just not clear as to what is causing the issue in the first place. Again though, thank you very much for your help with this!

That makes perfect sense, and I can now see why those 3 features in particular were an issue. Thank you very much for helping me with this @caracadrian​. You saved me what likely would have been many more days of frustration. Have a wonderful day/night!

Reply