Question

Looping through a tester

  • 9 December 2015
  • 9 replies
  • 9 views

For a project I'm working on I would like to make postal code areas which borders are nearby streats. To be able to do this I first turned the roads in to polygons. Next I would like to clip the postal code data to the area of the polygon it would fall into. Hereby it's very important that only one, of the many, polygons gets selected at the same time, as I only want the points which lie in one particular polygon to form voronoi polygons with eachother. The goal is to do this without using a python script and thus using only tools available in FME workbench. To be able to do this I wrote a simple looper which counts from 0 to 469. NWBpolyons are the road polygons, which I would like to select one by one. Adressen are the postal code points from which I would like to make Voronoi polygons within the road boundaries which surround them. The tester expression was quite simple in my mind. With the counter I count the polygons in the dataset, the attribute is called _count and the loop result is called _creation_instance. The tester expression thus is: _count = _creation_instance. My problem is that the tester won't run. Does anybody have an idea how to get the tester running, or how to surpass this problem?

regards, Bart


9 replies

Userlevel 2
Badge +12

I think a better way is creating the polygons from the roads and then use a FeatureReader to read the addresses per polygon. That way the polygons will processed one by one.

@erik_jan, could you deliberate on that answer a little more? I tried using the FeatureReader. I replaced the loop, the tester and the counter with the FeatureRead transformer, and it used the seperate polygons before the first clipper. But after that, all the clip results were merged together again before the Voronoi diagram was made. It's very important to only have points which lay within one polyon while making the voronoi diagrams, so postal code zones from across the street won't interfere with the others.

Userlevel 2
Badge +12

Both the Clipper and the VoronoiDiagrammer have a Group by option. In using the FeatureReader you have the option to merge the attributes of the streetpolygon and the addresses. Use the id of the streetpolygon as a Group by in the Clipper and the VoronoiDiagrammer. That way both will be processing per streetpolygon.

@erik_jan So if I understand you correctly, it should look something like this? I tried merging the data, but that just led to incredibly big data sets which I was unable to work with. Also the ID attribute is always zero or empty in the NWBpolyons output? Did I do something wrong? I can also only use the ID attribute to use the clipper. For the voronoi diagrammer it's impossible.

Userlevel 2
Badge +12

No @bartw. The FearureReader needs to be initiated by the polygons. That part is OK. But you want to read the addresses inside the FeatureReader, based on the spatial relation Interacting with its initiator. So the output of the FeatureReader needs to be addresses. The addresses read by the FeatureReader will go into the Clippe port, the initiator from the FeatureReader into the Clipper port. You do not need the addresses reader in your workspace at all as the addresses are read inside the FeatureReader.

@erik_jan, haha, I really start to feel like an idiot now. The orinial ID of the road dataset was 0, so I added the counter to give it an ID. With the first clipper I use group by _count, but then is doesn't run.

Badge +3

@bartw

You don't need to loop at all for this.

1 Create your roadgemetry. Use a BB or a hullaccumulator to create its areal coverage. Or if u have neighborhoodgemoetry (Buurt-vlakken for da dutch) that would be faster.

2 Clip or AoA Buurtgeometry with roadgeometry (for better performance dissolve roadgeo ). Clipper set to create aggregates = "no". (why in gn did fme put it standard to "yes"??)

3 Create a temp_ID on the result using a counter (always use different names for counter, common mistake..).

4 Spatialrelator and tester (or Spatialfilter or PointonArea) these area with adresses.

5 Create VoronoiCells grouped by temp_ID. Remember to use a StatisticsCalculator and tester to filter out temp_ID groups a< 3 else u can not us VC in group_by mode. The <3 groups u can use VC without group+by for.

6 Clip result by the the result of 3 (inner-road areas with temp_ID)

Dissolve VoronoiCells groupde by temp_ID and Postcode

Here is wb:

@gio that sounds like exactly what I wanted to do. Thanks for the help, i'll give it a go ;)

Badge +22

@bartw

You don't need to loop at all for this.

1 Create your roadgemetry. Use a BB or a hullaccumulator to create its areal coverage. Or if u have neighborhoodgemoetry (Buurt-vlakken for da dutch) that would be faster.

2 Clip or AoA Buurtgeometry with roadgeometry (for better performance dissolve roadgeo ). Clipper set to create aggregates = "no". (why in gn did fme put it standard to "yes"??)

3 Create a temp_ID on the result using a counter (always use different names for counter, common mistake..).

4 Spatialrelator and tester (or Spatialfilter or PointonArea) these area with adresses.

5 Create VoronoiCells grouped by temp_ID. Remember to use a StatisticsCalculator and tester to filter out temp_ID groups a< 3 else u can not us VC in group_by mode. The <3 groups u can use VC without group+by for.

6 Clip result by the the result of 3 (inner-road areas with temp_ID)

Dissolve VoronoiCells groupde by temp_ID and Postcode

Here is wb:

@gio For the Clipper change the aggregates to No then save as my defaults.

Reply