Solved

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

  • 5 January 2018
  • 5 replies
  • 81 views

Badge +2

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.

 

icon

Best answer by jdh 5 January 2018, 18:28

View original

5 replies

Badge +22

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

Badge +2

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)?

 

 

Badge +22
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.

 

 

Badge +2
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.

 

 

Badge +5

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

Reply