Skip to main content
Solved

Generic attribute from FeatureReader


danilo_fme
Evangelist
Forum|alt.badge.img+42

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

Best answer by erik_jan

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:

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

6 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • Best Answer
  • June 22, 2017

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:


danilo_fme
Evangelist
Forum|alt.badge.img+42
  • Author
  • Evangelist
  • June 22, 2017

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


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • June 22, 2017
danilo_fme wrote:

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.

 

 


mark2atsafe
Safer
Forum|alt.badge.img+43

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.


takashi
Supporter
  • June 23, 2017

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.


takashi
Supporter
  • June 23, 2017
erik_jan wrote:

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.

 


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