Skip to main content
Question

looping attributes - create features

  • 11 December 2012
  • 3 replies
  • 7 views

Hi, I want to create a point for each species

 

row 11, need create 3 points with the column name as an attribute

 

 

 

NB the source data has approx 50 columns

 

 

 

 

 

 

 

OBJECTID * SHAPE * WPT East North Date Azolla_filiculoides Blechnum_minus Carex_breviculmis Carex_geminata Carex_maorica Carex_ressectans Carex_secta Carmichaelia_corrugata Centella_uniflora Cheilanthes_sieberi Cordyline_australis Crassula_colligata_subsp_colligata Dichondra_repens 1 Point 26 2461536 5747297 4/12/2012                           2 Point 27 2461489 5747326 4/12/2012     x                   x 3 Point 28 2461468 5747298 4/12/2012               x           4 Point 29 2461491 5747229 4/12/2012                           5 Point 30 2461469 5747199 4/12/2012               x           6 Point 31 2461437 5747167 4/12/2012               x           7 Point 32 2461419 5747160 4/12/2012                           8 Point 33 2461396 5747017 4/12/2012                           9 Point 34 2461347 5746960 4/12/2012                           10 Point 35 2461399 5747254 4/12/2012                           11 Point 36 2461400 5747277 4/12/2012               x       x x 12 Point 37 2461039 5747366 4/12/2012                           13 Point 38 2461035 5747371 4/12/2012                           14 Point 39 2461026 5747372 4/12/2012                           15 Point 40 2460993 5747337 4/12/2012                           16 Point 41 2460963 5747338 4/12/2012                           17 Point 42 2460986 5747340 4/12/2012     x                   x 18 Point 43 2461053 5747351 4/12/2012                           19 Point 44 2461514 5746925 4/12/2012                            

 

 

 

 

 

Cheers

 

Brian

 

 

 

So you want to use the Cloner to clone each feature 3 times?

 

 

 


Hi, the data i posted didnt display fully.  Cloner was a suggestion i recived elsewhere however i fumbled around with python and manged to achieve what i was after

 

 

Effectively load multiple attributes into ONE attribute with a pipe seperator.  

 

Counter to group common locations

 

Attribute splitter to create a list

 

List exploder

 

Then used randomgenerator for xy to to offset common locations

 

 

 

import fmeobjects # Template Function interface: def countZZ(feature):     concat =""     VegCount = 0     for attr in feature.getAllAttributeNames():                           tmpAttrVal = feature.getAttribute(attr)         if (tmpAttrVal == 'x'):             if (concat == ''):                 VegCount = 1                 concat = attr             else:                 VegCount += 1                 concat = concat + "|" + attr     feature.setAttribute("AllVeg", concat)     feature.setAttribute("AllVegCount", VegCount)  

 


Hi Brian,

 

 

Is this a second post - thought I had responed to your earlier question on the same problem but it seems to have vanished?  Anyway here are some steps I think you need ...

 

 

Firstly, it is my understanding from your earlier post that there are (x) number species attributes and for each record only "some" of these are populated.  The number populated changes from record to record, i.e. it is not always 3. 

 

 

Secondly you only want to keep the attributes that are populated, i.e. for each point feature created, drop its NULL attributes.

 

  1. For each record species combination, enter a value of "1" in the cell (do this in Excel)
  2. Sum all the species attributes for each record - this will give you a species count (AttributeCreator)
  3. Using a cloner transformer set the number of copies to your sum value created in step 2 (Cloner)
  4. You now have one point per species type populated per record, but many of these points have NULL attributes which you need to drop - using an AttributeExploder create an attribute name/value pair for each attribute - created as _attr_name and attr_value (set Keep attributes = Yes)
  5. Identify all the NULL attributes by testing where _attr_value is NULL (Tester); for the data that passes the attribute _attr_name contains the name of an attribute that needs to be droppped
  6. The AttributeExploder will have changed the original table structure (exploded it) so now we should be able to return to the original format using an Aggregator transformer - setting GroupBy on OBJECT_ID and setting "Attributes to Concatenate = _attr_name" - this will now give us a "concatenated list" of NULL attribute names to be dropped
  7. Now pass attribute _attr_name (concatenated list) to a FMEFunctionCaller transformer and invoke the remove attributes function like this "@RemoveAttributes((@value(_attr_name)))"

 

This is untested but it makes sense in my head - give it a go :-)

 

 

Regards

 

Mike

Reply