Question

How to perform a Majority Filter operation on tiled vectors?

  • 14 November 2018
  • 6 replies
  • 11 views

I've got some continuous rectangles(polygons), each of them represents an atrribute value from 1 to 5. So after symbolization they just look like a raster. Some of the rectangles have abnormal values such as 1 rectangle has value 1 surrounded by 8 rectangles have value 5. I'd like to change 1 into 5 in order to clean the data. Due to the polygons are rectangles not squares, I can't convert them into raster to perform a Majority Filter operation in ArcGIS.

Is there a way to perform same operation on vectors? I'm thinking about creating a list to store surrounded rectangles' value, then use ListHistogrammer to get most frequence value if they appear equal or more than half, then change centre value in it. I've tried to put data through SpatialRelator's requestor and candidate port to create the list, but I can't ignore the centre rectangle which creates 9 listelements.

I'm struck here, if you have any suggestions or a better/more efficient method, please help me, I'm all ears, thank you.

@takashi @david_r @Mark2AtSafe @DaveAtSafe


6 replies

Userlevel 4
Badge +25

Are the rectangles all equally sized and equally spaced? Because you could turn them into raster in FME with the NumericRasterizer, which does allow rectangular raster cells. Then the RasterConvolver transformer has a Majority option.

Took some experimenting to get the Nodata settings correct, but I think I have it now.

Here's a template workspace that demonstrates the technique.

I hope it's of use.

Badge +22

I don't see why your SpatialRelator/ListHistogrammer idea wouldn't work.

If you send your data to both the Requestor and Supplier ports and set the Spatial Predicates to Test to "Requestor Touches Supplier", you will end up with the 8 neighbours in your list.

If you set it to "Requestor Intersects Supplier", you will end up with the 8 neighbours plus the central rectangle.

 

 

If you want just the neighbours and your data isn't perfectly clean such that there are minor overlaps, you can add a unique id on each polygon (Counter) , use "Requestor Intersects Supplier but set the Attributes that Must Differ parameter to the uniqueID attribute.

I don't see why your SpatialRelator/ListHistogrammer idea wouldn't work.

If you send your data to both the Requestor and Supplier ports and set the Spatial Predicates to Test to "Requestor Touches Supplier", you will end up with the 8 neighbours in your list.

If you set it to "Requestor Intersects Supplier", you will end up with the 8 neighbours plus the central rectangle.

 

 

If you want just the neighbours and your data isn't perfectly clean such that there are minor overlaps, you can add a unique id on each polygon (Counter) , use "Requestor Intersects Supplier but set the Attributes that Must Differ parameter to the uniqueID attribute.

Oops, I forgot the touch rule. And the last advice is really helpful, because some rectangles are just related to less than 8 candidates while I can clearly see they're surrounded by 8 under touch tule. I got the result which I expected.

It's really wired, theses rectangles are splitted from a big rectangle. I tried AreaOnAreaOverlayer method to detect gaps and overlays, it will output some when I set tolerance as none. But it will output nothing when I set tolerance as 0.001 under projection coordinate system. Is there a tolerance I can set in SpatialRelator?

Are the rectangles all equally sized and equally spaced? Because you could turn them into raster in FME with the NumericRasterizer, which does allow rectangular raster cells. Then the RasterConvolver transformer has a Majority option.

Took some experimenting to get the Nodata settings correct, but I think I have it now.

Here's a template workspace that demonstrates the technique.

I hope it's of use.

Eh, I see the link you posted is from dropbox, sadly I can't access dropbox directly, can you post a screenshot, please?

Userlevel 1
Badge +21

Do you need to consider polygons that touch at corners differently to those that share edges?

Do you need to consider polygons that touch at corners differently to those that share edges?

No, in this case they're considered as same. But I'd like to know how to distinct them in case I'll to do so in the future, thanks.

Reply