Solved

Generic attribute from FeatureReader

  • 22 June 2017
  • 6 replies
  • 53 views

Userlevel 5
Badge +30

Hello User's,

I have a folder with two differents schema Shapefiles. My Workflow has a transformer Creator and FeatureReader, and i would like to extract the attributes through the transformer FeatureReader.

Has the configuration inside transformer FeatureReader the Generic Port:

I can't configurate manually the attributes from the source datas because on this folder will have a differents datas with differents schemas.

My question: how can i configurate to be dynamic?

Attached my template file.

Thanks in Advance,

Danilo de Lima

icon

Best answer by erik_jan 22 June 2017, 19:46

View original

6 replies

Userlevel 2
Badge +16

Use the dynamic option on the writer.

Lead both the Generic data and the Schema from the FeatureReader to the output.

And tell the output feature type to take the schema from the Schema object:

Userlevel 5
Badge +30

Hello @erik_jan, thanks your help :)

I have a question: i would like extract the geometries and attributes after this transformer FeatureReader to work along my Workflow.

Thanks

Userlevel 2
Badge +16

Hello @erik_jan, thanks your help :)

I have a question: i would like extract the geometries and attributes after this transformer FeatureReader to work along my Workflow.

Thanks

In the FeatureReader you have the option to expose the attributes.

 

But that requires you to know what attributes are available and using a generic reader that usually is not the case.

 

For the geometry you can use the GeometryExtractor transformer.

 

 

Userlevel 4
Badge +26

Hi @danilo_inovacao - I guess the question is, how can you work with the attributes if you don't know what they are going to be? But if you do know what they will be, then you can use the option to expose them!

 

 

The only way to work with attributes when you don't know their name is to also read the schema with the FeatureReader so you have the information about what is available. Then you could merge that onto the main features and update the attributes using something like: @Value(attribute{x}.name) = abcd

Here is a workspace that does that. It changes the third attribute (here ParkName) to something different. But it's fairly restrictive over what it can do (eg it would always need to be the third attribute in the schema).

Hope this helps.

Userlevel 3
Badge +17

Hi @danilo_inovacao, as @erik_jan mentioned, the GeometryExtractor can be used to extract the geometry as an attribute value. Regarding attributes, you can use the AttributeExploder to "extract" pairs of attribute name and value as regular attributes or list elements. However, I don't know if it's your requirement.

What do you mean "extract the geometries and attributes" in the context? If you need to manipulate feature attributes with a regular transformer in the subsequent workflow, possibly you will have to expose their names manually with the AttributeExposer anyway.

Userlevel 3
Badge +17

Use the dynamic option on the writer.

Lead both the Generic data and the Schema from the FeatureReader to the output.

And tell the output feature type to take the schema from the Schema object:

If you intend to write each feature into a destination feature type with the same name as its source feature type, you should set "fme_feature_type" to the Shapefile Name field, rather than "fme_feature_type_name".

 

"fme_feature_type_name" is an attribute of the schema feature, and the data features usually don't have "fme_feature_type_name". If you set "fme_feature_type_name" to the Shapefile Name field, the writer cannot determine destination feature type for each feature, unless you have added "fme_feature_type_name" to every feature before writing.

 

Reply