Skip to main content

I'm looking for some advice to get me started on creating a workflow. I'm an intermediate FME user but this problem has got me stumped!

 

I'm dealing with roughly 100 areas that require tree planting. Each planting area will be a different size depending on the environment. Once each area is planted, we need to monitor 20% of the area to determine the success rate. The monitoring plots are 10 x 10 metres, so area of 100 sqm.

 

The plots need to be placed at random and I need to find out how many monitoring plots can be fit wholly within a planting area where the total area of the plots is at least 20% of the total planting area. For example, if the planting area is 3000sqm, I would need to assign 6 x plots.

20% of 3000 is 600. 600sqm would be 6 x plots.

 

Any help or advice would be appreciated.

I like this problem!

1) Are the monitoring plots always squares or can they have any shape?

2) If a planting area is not nicely divisible by 100m², would you round up or down? E.g. a planting area of 3050m² needs 610m² of monitoring plots: are these 6 or 7 plots? Same question for 680m² of monitoring plots ;)


@joepk​ Thank you for commenting :)

 

  1. The monitoring plots will always be 10x10m squares.
  2. The planting areas will come in all different shapes and sizes. So long as the monitoring plots cover minimum 20% of the planting area that will be fine. Our guidlines state 20-25%, in other words minimum 20%.

 

Currently I have a rough idea for the start of the workbench, calculate per centages and the required number of plots to occupy 20% of the planting area. But i'm not sure how to assign the plots at random. I have played with the random point generator before but not pre-defined polygons.


@joepk​ Thank you for commenting :)

 

  1. The monitoring plots will always be 10x10m squares.
  2. The planting areas will come in all different shapes and sizes. So long as the monitoring plots cover minimum 20% of the planting area that will be fine. Our guidlines state 20-25%, in other words minimum 20%.

 

Currently I have a rough idea for the start of the workbench, calculate per centages and the required number of plots to occupy 20% of the planting area. But i'm not sure how to assign the plots at random. I have played with the random point generator before but not pre-defined polygons.

I would do something like this to generate a random 10x10m plot inside another polygon:

imageA problem with this flow would be that if the first couple of plots are placed awkwardly, the rest of the plots won't fit anymore. To overcome this you would have to maybe give the RandomNumberGenerators more restrictions, but this would remove some randomness.

 

I also don't really have time to figure out the looping part now.. There might be some issues with adding multiple loops and having blocking transformers.

 

Hope this kind of helps. And I am very interested in reading how you are going to tackle this.


Hi @frank_herbert​ ,

Not ideal but hopefully it is helpful.

random_plots


Hi @frank_herbert​ ,

Not ideal but hopefully it is helpful.

random_plots

Version 2. Looks more randomly?

random_plots_v2


Thank you for your suggestions @joepk​ and @Takashi Iijima​  😀

I have experimented with both workflows are they seem to work well. I have requested my organisation updates my version of FME this week so I can get a better look at takashi's v2 workflow.

One thing that always facinates me about FME is how the experts can achieve the outcome with much fewer transformers. I think my original workbench would have been much longer!

I will post an update on this towards the end of the week when I can apply the final touches.

Thanks again for your help and wisdom.


Version 2. Looks more randomly?

random_plots_v2

@takashi please can you post a screenshot of the workbench with summary annotations enabled? My organisation will not allow me to update my version of FME so I can't see all of the transformers. I'm trying to get it updated but will probably take months where I am based.


Version 2. Looks more randomly?

random_plots_v2

Hope this the attached screenshot is helpful.

The Counter_3 create unique "_index".

 

The script in the PythonCallser is:

import fme
import fmeobjects
 
class FeatureProcessor(object):
    def __init__(self):
        self.features = {}
 
    def input(self, feature):
        index = int(feature.getAttribute('_index'))
        self.featuresaindex] = feature
 
    def process_group(self):
        while self.features:
            _, feature = self.features.popitem()
            relations = feature.getAttribute('_relationships{}._index')
            if relations:
                for index in tint(i) for i in relations]:
                    if index in self.features:
                        del self.featuresoindex]
            self.pyoutput(feature)
        self.__init__()
 
    def close(self):
        pass
 
    def has_support_for(self, support_type):
        if support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM:
            # If this is set to return True, FME will pass features to the input() method that
            # come from a feature table object. This allows for significant performance gains
            # when processing large numbers of features.
            # To enable this, the following conditions must be met:
            #   1) features passed into the input() method cannot be copied or cached for later use
            #   2) features cannot be read or modified after being passed to self.pyoutput()
            #   3) Group Processing must not be enabled
            # Violations will cause undefined behavior.
            return False
 
        return False

workspace-example


Version 2. Looks more randomly?

random_plots_v2

Awesome! Thank you @Takashi Iijima​ 😀


Reply