Skip to main content
Solved

Looping to run the workspace for each attribute


Hello,

I have a shapefile with approximately 200 tiles that contains an attribute value for each (e.g. 52A, 52B...). I am trying to output the data where each individual tile or attribute is applied with a SpatialFilter (contains and touches). The only way I know going about it is by using a Tester and changing the values manually each time I run the workspace. I know a loop can be applied to the workspace but I couldn't find any guidance or documentation on dealing with this.

Thank you,

Best answer by takashi

Hi @joeli, Loop can be implemented in a custom transformer, but I don't think the loop is a suitable solution in this case. Probably you can use the SpatialRelator and ListExploder to get your required result by running the workspace just once.

  1. SpatialRelator: Send the current Candidate features (TileSample [SHAPE] -2) to the Requestor port, send the current Filter features (TileSample [SHAPE] -1) to the Supplier port after renaming their Tile_Name to Tile_Name2.
  2. ListExploder: Connect a ListExploder to the Output port of the SpatialRelator, and select "_relationships{}" for the List Attribute parameter. This duplicates the Requestor feature by the number of spatially related Supplier features.

The writer feature type will write the features into different feature types depending on the Tile_Name2 value, since you have set the attribute to the feature type name.

View original
Did this help you find an answer to your question?

3 replies

takashi
Contributor
Forum|alt.badge.img+21
  • Contributor
  • Best Answer
  • April 12, 2016

Hi @joeli, Loop can be implemented in a custom transformer, but I don't think the loop is a suitable solution in this case. Probably you can use the SpatialRelator and ListExploder to get your required result by running the workspace just once.

  1. SpatialRelator: Send the current Candidate features (TileSample [SHAPE] -2) to the Requestor port, send the current Filter features (TileSample [SHAPE] -1) to the Supplier port after renaming their Tile_Name to Tile_Name2.
  2. ListExploder: Connect a ListExploder to the Output port of the SpatialRelator, and select "_relationships{}" for the List Attribute parameter. This duplicates the Requestor feature by the number of spatially related Supplier features.

The writer feature type will write the features into different feature types depending on the Tile_Name2 value, since you have set the attribute to the feature type name.


mark2atsafe
Safer
Forum|alt.badge.img+43
  • Safer
  • April 12, 2016

I'm with Takashi here - I don't think a loop is the best way.

It looks to me that you want to match tiles in the two datasets, but only where there is a matching attribute. In that case, can you simply set a Group-By in the SpatialFilter? Does that produce the result you want? Otherwise, again, I'm with Takashi that a ListExploder is probably the way to go.


  • Author
  • April 12, 2016

Thank you for the quick response! I've used @takashi method and it worked out perfectly.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings