Question

How do I divide polygons (dissolved contiguous hexagons), or divide point clusters (from hexagon centre points) into minimum and maximum class or cluster sizes?

  • 2 October 2018
  • 3 replies
  • 6 views

Badge

I have two ways I've been going about this.

1 - dissolving hexagons, keeping any at least 3 contiguous hexagons in size. Any more than 20 hexagons in size need to be divided into being at least 3 contiguous hexagons in size. I've used the PointClusterer transformer (on the centre points) when I had only 2 large polygons that needed to be divided, however, when I have over 12 polygons it's not working so well (perhaps due to the irregular spatial distribution and oddly-shaped polygons).

2 - I've looked at trying to divide the polygons directly, with less success (trying to determine the length and width didn't work so well with the irregularly-shaped polygons from the dissolved hexagons).

Does anyone have any idea of how to make either method work, or have another idea of how to do this?


3 replies

Userlevel 4
Badge +25

Let me see if I understand this right. You have a dataset of hexagons, and you want to group them together (or dissolve them together) where each group has a size between 3 and 20 hexagons. Correct?

I can think of some different approaches; what I'd try if I were tasked with this.

The first approach would be to try iteration. Use the NeighborFinder to get a list of neighbors for each hexagon. Then dissolve, say, three of them together. Now repeat the process adding a new hexagon to the merge for every iteration. If you hit 20 features then stop, and restart the process beginning with a new source hexagon. Basically looping/iterating through the data.

That approach gives you more guaranteed success, but it would be way harder to implement. Looping in FME is fairly tricky when you have group-based processes in there like the Dissolver. You could just create a single feature, with an FME "list" of all hexagons, and pull them out of the list one at a time. That way you only work on a single feature and looping is easier. But to merge the geometry... well since they are hexagons (of known size?) just discard the actual geometry and construct it as you go during the loop. Once you hit 20 hexagons, that feature exits but you continue with what's left of the list.

So tricky, but the more I think about it, the more possible I think it would be with lists.

The second approach I can think of is a clustering/grouping method. You've already tried the PointClusterer. The other custom transformer I can think of is called the SpatialSorter. It sorts data spatially, and you can group features together on that basis, with a group of X features.

That approach is not as guaranteed successful (in the same way you've had problems with the PointClusterer) but it is way easier to implement. Just drop down the SpatialSorter, set a group size, and run your data through it. However, the transformer does work on all data at once. Since you have a number of sets of hexagons, you might need to modify it to work on one group at a time (or use batch processing, where each batch is a single polygon/set of hexagons).

Finally, you could use a combination of these two. The SpatialSorter was designed to work with data at random locations (such as points), not necessarily organized into contiguous hexagons. Since we know you have data that edge matches, you could try to edit the SpatialSorter so that it not only groups the data in a spatially sorted order, but that the features must also be neighbors.

Perhaps run the SpatialSorter and get features so they are sorted. Then you have data pre-sorted for neighbor matching? Just throwing out some suggestions.

Anyway, the first thing to try would be the SpatialSorter. It would be easy to run your data through it. That might be the solution you need... or you might need to work on it some more.

Hope this helps. Like I said, if I had to do this, those are the directions I'd explore first.

Userlevel 4
Badge +25

Oh, since you are working with hexagons, another solution that occurs is to number each of them with a makeshift coordinate system. I came up with a numbering system before where each column of hexagons was a different X value, and each row of hexagons a different Y value. It's slightly tricky because these are not rectangles. If you have pure columns of hexes, then the rows are not contiguous. So the Y axis gets twice as many values.

ie my columns of hexagons are numbered:

  • Column 1: 1,1; 1,3; 1,5; 1,7
  • Column 2: 2,0; 2,2; 2,4; 2,6
  • Column 3: 3,1; 3,3; 3,5; 3,7
  • Column 4: 4,0; 4,2; 4,4; 4,6
  • etc

Which would probably make more sense when you are looking at a grid of hexagons.

Anyway, with the numbering, you could probably create a string of contiguous hexagons by following from hex to hex using the coordinates. With a square grid, you have four directions to move in:

  • North: y=y+1
  • South: y=y-1
  • West: x=x-1
  • East: x=x+1

But with a hex grid there are six directions:

  • North: y=y+2
  • South: y=y-2
  • North-West: x=x-1, y=y+1
  • North-East: x=x+1, y=y+1
  • South-West: x=x-1, y=y-1
  • South-East: x=x+1, y=y-1

So, you just jump from hex to hex (maybe a list again) until you reach your desired group size. And you can check if hex 3,5 (for example) exists with a ListSearcher. It would be another way to do it.

Anyway, I don't know if this helps you in any way, but I find the idea of a hex-based coordinate system fascinating.

Badge

Thanks for your suggestions, @

Mark2AtSafe

I did end up doing a more manual # cluster selection / iteration process. Now I'm thinking that if there was some way I could figure out setting up a block to run the point clustering per large polygon, that could work too. Haven't had any luck with that type of iterative process in FME yet though. It would need to include a Dissolver, so maybe that wouldn't work either...

Reply