Question

How to read folders and pipe filenames for processing?

  • 14 August 2018
  • 3 replies
  • 78 views

Badge +8

Hi!

Working with Sentinel data, you get some 120 files i a zip file (standard download). Only three are needed to make an rgb image with FME (as described in this post: https://knowledge.safe.com/articles/43742/making-rgb-images-with-sentinel-data.html).

This workspace snippet begins to extract these file names and should then pipe them to the next step (there is more to follow). But I am unable to figure out what goes into the gap between the TestFilter and the RasterBand... transformer. I simply need to get the path_windows attribute to be understood as an input file.


3 replies

Userlevel 2
Badge +17

Hi @matself, the PATH reader just reads the information of files such as file paths, file names, extension etc. If you need to read the raster files after filtering their file paths by the TestFilter, consider using the FeatureReader transformer.

Badge +8

Thanks @takashi. That pointed me in the right direction.

So here is what I did. I filtered out the three files and piped them through the initiator of the FeatureReader as suggested. But I was not able to figure out how to create three outport ports dynamically, by using the filename or any other attribute. So I ended up by taking the Generic port and TestFilter that output to split the flow into three streams. Basically the same test as before the FeatureReader which seems like an awful convoluted detour. Anyway, from that point on the workspace ran like before, and I can now process the RGB bands from a standard Sentinel scene into a natural color image only by selecting the folder path.

Userlevel 2
Badge +17

Thanks @takashi. That pointed me in the right direction.

So here is what I did. I filtered out the three files and piped them through the initiator of the FeatureReader as suggested. But I was not able to figure out how to create three outport ports dynamically, by using the filename or any other attribute. So I ended up by taking the Generic port and TestFilter that output to split the flow into three streams. Basically the same test as before the FeatureReader which seems like an awful convoluted detour. Anyway, from that point on the workspace ran like before, and I can now process the RGB bands from a standard Sentinel scene into a natural color image only by selecting the folder path.

Firstly you can filter the file paths with the Path Filter parameter in the PATH reader. See here to learn more about the Path Filter: Directory and File Pathnames Reader Parameters

 

Then, you can filter the raster features based on their file names if you exposed "fme_basename" which stores source file name without extension, in the FeatureReader.

 

e.g.

 

Reply