Skip to main content
Solved

How to extract the actual shapefile from FeatureReader (geometry and attributes)


robertr
Contributor
Forum|alt.badge.img+6

Hello,

 

I am using a "Directory and File Pathnames" reader to pull shapefiles from a folder.

 

I then walk them through a tester to filter out the files that I do not need. All good and working up to this point. The goal is to work on those shapefiles and have a processed shapefile as an output, in the end.

 

 

After the tester, I send the "passed" ones to a "FileReader" that outputs the desired features under the <Generic> port.

 

 

My question is: how can I write those out and keep the geometry + attributes of the shapefiles for future processing?

 

 

I can see them in the Inspector but I cannot figure out how to move on to the next step as the only attributes I see imported to any transformer I add, are the ones from the "Directory and File Pathnames" reader, not the shapefiles themselves.

Long story-short, I want to use the shapefiles that passed the "Tester" as readers.

 

Best answer by jdh

If you want to manipulate the attributes you need to explicitly expose them on the featureReader, if you only want to write them, you can use the dynamic setting on the writer. See https://knowledge.safe.com/articles/1157/dynamic-workflow-tutorial-destination-schema-as-a.html

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

5 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • Best Answer
  • January 5, 2018

If you want to manipulate the attributes you need to explicitly expose them on the featureReader, if you only want to write them, you can use the dynamic setting on the writer. See https://knowledge.safe.com/articles/1157/dynamic-workflow-tutorial-destination-schema-as-a.html


robertr
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • January 5, 2018
jdh wrote:

If you want to manipulate the attributes you need to explicitly expose them on the featureReader, if you only want to write them, you can use the dynamic setting on the writer. See https://knowledge.safe.com/articles/1157/dynamic-workflow-tutorial-destination-schema-as-a.html

I want to both manipulate the attributes and to write them after manipulation.

 

I always want all the attributes exposed.

 

Basically I want to add as readers all the shapefiles that have a certain text in the name.

 

 

I find it very cumbersome to specify all the attributes that I want exposed.

 

 

Am I totally using the wrong readers to accomplish a task that seems very basic and simple (get a handful of shapes and add them as readers)?

 

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 5, 2018
robertr wrote:
I want to both manipulate the attributes and to write them after manipulation.

 

I always want all the attributes exposed.

 

Basically I want to add as readers all the shapefiles that have a certain text in the name.

 

 

I find it very cumbersome to specify all the attributes that I want exposed.

 

 

Am I totally using the wrong readers to accomplish a task that seems very basic and simple (get a handful of shapes and add them as readers)?

 

 

You can vote on this idea https://knowledge.safe.com/idea/24774/add-import-function-to-featurereaders-attribute-to.html to improve exposing attributes.

 

 

The issue is that the shapefiles to be read in are only determined at run time, so FME has no information as to the schema, until the process has started, so it cannot automatically make the attributes available on the canvas to work with. The attributes are carried on the feature, and are available to the writer (via dynamic schema).

 

 

If you don't want to explicitly expose the attributes to manipulate them, then your other choice is to add a Merged shapefile reader and use wilcards in the merge filter of the feature or in the SourceDataSet parameter or both.

 

That will give you a one-time combined set of attributes of all the files you read in when you added the reader, if the files change, or the attributes in the files change, this will not be reflected on the reader.

 

 


robertr
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • January 5, 2018
jdh wrote:
You can vote on this idea https://knowledge.safe.com/idea/24774/add-import-function-to-featurereaders-attribute-to.html to improve exposing attributes.

 

 

The issue is that the shapefiles to be read in are only determined at run time, so FME has no information as to the schema, until the process has started, so it cannot automatically make the attributes available on the canvas to work with. The attributes are carried on the feature, and are available to the writer (via dynamic schema).

 

 

If you don't want to explicitly expose the attributes to manipulate them, then your other choice is to add a Merged shapefile reader and use wilcards in the merge filter of the feature or in the SourceDataSet parameter or both.

 

That will give you a one-time combined set of attributes of all the files you read in when you added the reader, if the files change, or the attributes in the files change, this will not be reflected on the reader.

 

 

I appreciate you taking time to help out.

 

I guess I can expose the attributes. My only frustration with this is that I never know how many shapefiled there will be in the folder and I am not so sure all will have the same attributes as to be able and construct the writer and other transformers appropriately.

 

 

I will continue to tweak Python scripted parmas + your suggestions to see with what I can come up.

 

 


marias
Contributor
Forum|alt.badge.img+8
  • Contributor
  • April 23, 2024

Hi, has anything changed for this transformer over these years?  I need FeatureReader to read all attributes, preferably without exposing, since they may vary. 


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