Skip to main content

I have created a crosswalk from multiple shapefiles that a) reads a look up table b)writes the values to a geodatabase and c)populates a field called "DataSource" with the source shapefile names. I have a field called "city" that needs to have city values populated based on the value in the "DataSource" field. My approach was to set a condition statement in the target field properties of the writer using If/Else If/Else statements. Didn't work. Please see screen caps showing parameters and desired outcome.

I have never tried to do this from the writer but your approach will work if you follow the same process using the attributecreator or attributemanager


Hi @daveyourguide, I think conditional value setting for user attributes in a writer feature type should work as expected (at least in FME 2016.1.3). Make sure that the attribute names and values written in the Test Condition column are exactly match ones that the features could have. Note that FME identifies attribute names and values with case-sensitive. e.g. "dataSource" as an attribute name will be distinguished from "DataSource".


However, I think it would be better to create a new attribute called "city" with a transformer beforehand, from the point of view for better maintainability of the workspace. As @ciarab mentioned, you can create a new attribute with conditional value setting using the AttributeCreator or the AttributeManager. Alternatively, you can also use the AttributeValueMapper in this case.


Hi @daveyourguide, I think conditional value setting for user attributes in a writer feature type should work as expected (at least in FME 2016.1.3). Make sure that the attribute names and values written in the Test Condition column are exactly match ones that the features could have. Note that FME identifies attribute names and values with case-sensitive. e.g. "dataSource" as an attribute name will be distinguished from "DataSource".


However, I think it would be better to create a new attribute called "city" with a transformer beforehand, from the point of view for better maintainability of the workspace. As @ciarab mentioned, you can create a new attribute with conditional value setting using the AttributeCreator or the AttributeManager. Alternatively, you can also use the AttributeValueMapper in this case.

Hello @takashi, thank you for your answer. I revised this response because I had some success since I first responded. I was partially successful in populating the city field with the three values based on the source value conditions in the dataSource field using the AttributeValueMapper. I created a separate workspace to run the value mapper from the initial crosswalk in order to keep things simple. Problem is that it appends the records rather than update the existing ones. The problem seems to be in the Format Parameters settings in the writer. Using "Update" for the feature operation yields no results. The Insert appends records and the only successful method is to employ the fme_db_operation, but this also appends. Hope this makes sense. Please see screen captureattributevaluemapper-1.png

 

Thanks

 


Hello @takashi, thank you for your answer. I revised this response because I had some success since I first responded. I was partially successful in populating the city field with the three values based on the source value conditions in the dataSource field using the AttributeValueMapper. I created a separate workspace to run the value mapper from the initial crosswalk in order to keep things simple. Problem is that it appends the records rather than update the existing ones. The problem seems to be in the Format Parameters settings in the writer. Using "Update" for the feature operation yields no results. The Insert appends records and the only successful method is to employ the fme_db_operation, but this also appends. Hope this makes sense. Please see screen captureattributevaluemapper-1.png

 

Thanks

 

Do you perhaps need to update the records in an existing File Geodatabase feature class, with adding the new attribute called 'city'? If so, there are some considerations as below.

 

  1. The 'city' field should have been defined in the feature class schema. If the 'city' field has not exist yet, you have to add the field definition to the feature class with an appropriate tool, such as ArcCatalog.
  2. Then, set 'Update' to the Feature Operation parameter. Alternatively you can set 'fme_db_operation' to the parameter like your screenshot. However, if you do so, you will have to add the 'fme_db_operation' attribute storing 'UPDATE' as its value to every feature before writing.
  3. And you should set only unique ID attribute(s) to the Match Columns parameter. If you read existing records and just update them, the 'OBJECTID' could be used as the unique ID for the records.

Do you perhaps need to update the records in an existing File Geodatabase feature class, with adding the new attribute called 'city'? If so, there are some considerations as below.

 

  1. The 'city' field should have been defined in the feature class schema. If the 'city' field has not exist yet, you have to add the field definition to the feature class with an appropriate tool, such as ArcCatalog.
  2. Then, set 'Update' to the Feature Operation parameter. Alternatively you can set 'fme_db_operation' to the parameter like your screenshot. However, if you do so, you will have to add the 'fme_db_operation' attribute storing 'UPDATE' as its value to every feature before writing.
  3. And you should set only unique ID attribute(s) to the Match Columns parameter. If you read existing records and just update them, the 'OBJECTID' could be used as the unique ID for the records.

 

Hello @takashi,

 

I've tried everything that I can. I am working with a file gdb that contains both the source and destination fields. Therefore the reader points to the source field (sourceData) and the writer points to the destination (city). Every attempt runs successfully but does not write the value translation to the destination field.

 

I have attached the file gdb with a sample of the record that meet the conditions. I have also attached the FME workspace. Both are in the attached .zip. I hate to trouble you but if you can have a look it would probably save some time trying to explain what I have attempted. Thank you!testfme.zip
Hello @takashi, thank you for your answer. I revised this response because I had some success since I first responded. I was partially successful in populating the city field with the three values based on the source value conditions in the dataSource field using the AttributeValueMapper. I created a separate workspace to run the value mapper from the initial crosswalk in order to keep things simple. Problem is that it appends the records rather than update the existing ones. The problem seems to be in the Format Parameters settings in the writer. Using "Update" for the feature operation yields no results. The Insert appends records and the only successful method is to employ the fme_db_operation, but this also appends. Hope this makes sense. Please see screen captureattributevaluemapper-1.png

 

Thanks

 

"3. And you should set only unique ID attribute(s) to the Match Columns parameter. If you read existing records and just update them, the 'OBJECTID' could be used as the unique ID for the records."

 

Why not set only 'OBJECTID' to the Match Columns parameter?

 


"3. And you should set only unique ID attribute(s) to the Match Columns parameter. If you read existing records and just update them, the 'OBJECTID' could be used as the unique ID for the records."

 

Why not set only 'OBJECTID' to the Match Columns parameter?

 

@takashi - Success! That worked. Thank you very much for your patience and assistance.

 


I have never tried to do this from the writer but your approach will work if you follow the same process using the attributecreator or attributemanager

@ciarab - thanks for your input. The attributeMapper did the trick after some fidgeting. See below.

Reply