Question

How to read a TIF file without taking into account the associated TFW file ?


Hi, I need to validate if the TFW file content corresponds to the associated TIF file.

Therefore, I'm reading the TIF properties (with RasterPropertyExtractor) and I'm reconstructing the 6 TFW-paramaters, to compare them with the content of the TFW file.

But... the problem is that the Reader reads the TIF file with the parameters coming form the TFW file. Hence, if the TFW is wrong, then the TIF properties extracted with RasterPropertyExtractor are also wrong.

Is there a way to force FME to ignore the TFW file when reading a TIF ?

Thank you for your help.


2 replies

Badge +20

Try to create a copy of the TIF file in a TEMP location and read it from there without the TFW, then compare.Read TIF without TFWStart from a PATH Reader, send to TempPathnameCreator to create TEMP (FME clears it when it's done) then to AttributeManager where you create filecopy_source_dataset with value path_windows and filecopy_dest_filename with value @Value(_pathname)/@Value(path_filename) - needed in FileCopy Writer inserted as FeatureWriter.

Send AttributeManager output to a Tester with clause path_extension=tif.

Passed port goes to a FeatureWriter set as Format File Copy, Dataset path_windows. filecopy_source_dataset and filecopy_source_dataset set in Attribute manager earlier will do the heavy lifting.

Send Summary port output to a FeatureReader set as GeoTiff with Dataset as _dataset attribute and send Generic port to a RasterPropertyExtractor.

Now compare with the values stored in the TFW file with GroupBy set to filename without extension (path_rootname if you use the Failed port of the Tester to read TFW).

You mai need to expose some more attributes at FeatureWriter(File Copy) - Additional Summary Port Attributes (at least path_rootname to GroupBy) and set FeatureReader to Merge Initiator and Result in Attribute and Geometry Handling section.

Badge +20

Try to create a copy of the TIF file in a TEMP location and read it from there without the TFW, then compare.Read TIF without TFWStart from a PATH Reader, send to TempPathnameCreator to create TEMP (FME clears it when it's done) then to AttributeManager where you create filecopy_source_dataset with value path_windows and filecopy_dest_filename with value @Value(_pathname)/@Value(path_filename) - needed in FileCopy Writer inserted as FeatureWriter.

Send AttributeManager output to a Tester with clause path_extension=tif.

Passed port goes to a FeatureWriter set as Format File Copy, Dataset path_windows. filecopy_source_dataset and filecopy_source_dataset set in Attribute manager earlier will do the heavy lifting.

Send Summary port output to a FeatureReader set as GeoTiff with Dataset as _dataset attribute and send Generic port to a RasterPropertyExtractor.

Now compare with the values stored in the TFW file with GroupBy set to filename without extension (path_rootname if you use the Failed port of the Tester to read TFW).

You mai need to expose some more attributes at FeatureWriter(File Copy) - Additional Summary Port Attributes (at least path_rootname to GroupBy) and set FeatureReader to Merge Initiator and Result in Attribute and Geometry Handling section.

Here is a sample Workspace to get you started.

Forgot to upload in the initial post and can't add it via Edit.

Reply