0

I have a shp which needs to be split according to attributes in a field. The problem is that the field contains other Characters and dates. For Example the Field is called "Landtype" and contains the following "Woodland_20120502". The Date changes for each data record so I can´t just select all records with this value. I need to first select all records that have the word "Woodland" and then populate another field with the word "Woodland" in FME or ArcGIS modelbuilder or Python.

Could anyone advise me on how I would best do this?

  • 1
    Haven't used FME in a while, but how about a PythonCaller with a little function to parse out the date with something like "Woodland_20120502.split("_") and then slice up date to parse out the different pieces. This is assuming consistency with your example. – Chad Cooper May 16 '13 at 14:30
1

Two ways to do this.

First is to use the AttributeSplitter transformer.
Attribute to Split: Landtype
Delimiter or Format String: _
Time Whitespace: Both
List Name: _list
Drop Empty Parts: No

Expand the output of the AttributeSplitter. Right-click _list{} and choose Expose Elements and then enter 0, for only the first element, in the one input for Select List Elements. Now you will have an attribute called _list{0} that will contain everything in the Landtype attribute before the underscore.

The second option is to use the StringSearcher transformer and use a regular expression.
Attribute: Landtype
Regular Expression: ^(\w+)_

The list attribute to assign to Matched Parts Attribute will again contain a list which you can Expose in the same way as above to get the first element. Or optionally you could use the attribute assigned to Matched Result Attribute and the AttributeTrimmer to remove the trailing underscore.

0

In FME :

  1. StringSearcher > find using Regular Expression ^Woodland On the Output of StringSearcher you will have an attribute named _matched_charaters
  2. AttributeRenamer to rename att _matched_charaters to for example FEATURE_TYPE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.