Skip to main content

I am trying to convert a GeoTIFF to an Esri polygon shapefile or feature class, not a raster. The GeoTIFF is in WGS1984 which is fine, and contains grids that have stretched value and pixel value fields. I used a GeoTIFF reader and tried both Esri Shapefile and File geodatabase writers as output but I'm getting just one feature. I don't mind if every grid is a polygon since it's a small enough TIFF file that I can classify them after the shapefile/feature class is created but if I can do a simple transofmation to pre-identify classes to create fewer polygons that's fine, too.

I didn't see this capability in current ArcGIS as a direct approach, so I wonder if FME has a better way. Thanks for any assistance you can provide!

Hi,

have you tried RasterCellCoercer. It should create polygons and contain some attributes...


@zzupljanin, Thanks for your reply and for your assistance! I used the RasterCellCoercer as transformer between the GeoTIFF reader and Esri shapefile writer. It produced the 1,230 polygons that I expected and I get two variables: _band___va and _band___pa , but they are all null/blank valued and I am not able to enter attribute information into the transformer.

My entry for the RasterCellCorcer Parameters:

Output Cell Geometry: Polygons, Extract Band Values As: Attributes, Extract Nodata Values: Yes, Preserve Attributes: Yes, Raster ID Attribute: (don't know), Band ID Attribute: (can't enter - likely because of lack of Raster ID attribute?), Column Attribute: (don't know), Row Attribute: (don't know).

I don't know the exact variable names used in the GeoTIFF. Esri doesn't expose the variable names or the ID for each cell through its applications but knows what they are, calling them "Stretch value" and "Pixel value" in the GeoTIFF's properties. I have tried several combinations of guessing variable names with no success, and the GeoTIFF specification doesn't help me at all.

I'm not able to upload the GeoTIFF file here as a file or image, so I can't share my file with you via this forum message. I think I'm close but don't know what values to use. Any further help would be great!


@zzupljanin, Thanks for your reply and for your assistance! I used the RasterCellCoercer as transformer between the GeoTIFF reader and Esri shapefile writer. It produced the 1,230 polygons that I expected and I get two variables: _band___va and _band___pa , but they are all null/blank valued and I am not able to enter attribute information into the transformer.

My entry for the RasterCellCorcer Parameters:

Output Cell Geometry: Polygons, Extract Band Values As: Attributes, Extract Nodata Values: Yes, Preserve Attributes: Yes, Raster ID Attribute: (don't know), Band ID Attribute: (can't enter - likely because of lack of Raster ID attribute?), Column Attribute: (don't know), Row Attribute: (don't know).

I don't know the exact variable names used in the GeoTIFF. Esri doesn't expose the variable names or the ID for each cell through its applications but knows what they are, calling them "Stretch value" and "Pixel value" in the GeoTIFF's properties. I have tried several combinations of guessing variable names with no success, and the GeoTIFF specification doesn't help me at all.

I'm not able to upload the GeoTIFF file here as a file or image, so I can't share my file with you via this forum message. I think I'm close but don't know what values to use. Any further help would be great!

I too have no idea what kind of value is a Stretch value. But you can expose (AttributeCreator) Pixel values since they are given as list (of four bands in my case) for every polygon. Can you provide smaller data sample or give your data sample from other web sources (dropbox...)

 

 

 

 

In Attribute section of RasterCellCoercer you enter output attributes for ID, row, column...

 

Band Id Attribute is for case if you want to extract band values as Z values.

 

 

Cheers,

 

Zelimir

 

 


@zzupljanin, thanks again for your time! I've incorporated Attribute Creator into my Workbench file flow but it's not exposing any band variables. I don't know how to set parameters for it; if seems like the GeoTIFF is not exposing the variables.,

Here's the link to the GeoTIFF, a ZIP only 10KB in size: There's actually a TIFF image and TFW file that was created to comprise GeoTIFF. I assume that FME needs to know both files must be part of the solution but it only asks for the TIF image,

https://1drv.ms/u/s!AilAMWe4tc6xhmBUuBE-QQ25f810


Hi @pdituri, Thanks for posting this question.

 

I think @zzupljanin's suggest of RasterCellCoercer is a great one, You can also use a RasterToPolygonCoecer to convert adjacent raster cells with the same value into a merged polygon (instead of one polygon per cell).

 

I see the struggle is here mainly to do with retaining cell values as attributes, when writing to shapefile or file geodatabase. I looked at the raster, It doesn't appear that FME can see the stretched value, but we can sure extract the pixel value and write to the output.

The reason you were having trouble is related to 2 factors:

 

  1. When using RasterCellCoercer, the pixel values are stored in a list attribute, on each resulting polygon. You will need to use a special method to expose the list element. Here is the detailed instructions on how to do it. Since you only have one band, there is only one list element, and it's index is 0. (NOTE: clicking on the triangle on the left of RasterCellCoercer will expand the attributes, and you'll see _band{}.value. this is the list you want to expose).

     

    If you choose to use RasterToPolygonCoecer, it works a bit differently. It creates a regular attribute, _label, which stores pixel values. If there are multiple values, they will form a string that's comma separated. Since your raster only have one band, you don't have to worry about this.

     

  2. With the RasterCellCoercer result, there is another factor. Even after you exposed the list element, the name of the exposed attribute will be _band{0}.value. This is too long for Shapefile or file geodatabase attribute name, and also contain unaccepted characters. FME should automatically map it to an accepted name, but it will not be very readable (something like _band_0__v). So it's a good idea to rename this attribute using an AttributeManager, after exposing it as mentioned above. This article has some helpful details on how to use AttributeManager.

     

    You can also rename _label from RasterToPolygonCoecer output, if you wish to take that route.

Hope this helps a bit.

Thanks!

Xiaomeng


@XiaomengAtSafe, thank you for following up with me here and via e-mail! I made the simple error of not knowing how to expose attributes, but I discovered the right-click button on the RasterCellCoercer transformer to expose the values per your instructions. I now have a shapefile with a "band___va" variable name that I've decided doesn't need to go through AttributeManager, since I can always alias the field name on the ArcGIS side.

The new issue is that the "band___va" value is coming across as a float value - but within a text field. Thus I can't use that field for graduated values, since it's not float in the schema. I didn't see a way to convert that field from text to float in a transformer. I can do this with ArcGIS but am surprised that it isn't easier in FME - I must be missing something.

Also, I have to manually edit the exposed attributes in the writer every time I run the workspace and set the values manually to obtain the outputs. I saved the workspace after editing, but once I close and reopen FME and the workspace, the manually set values don't exist, and I have to do them again.

One last "discovery": I was unable to use the RasterToPolygonCoercer because it didn't expose the attributes as the RasterCellCoercer did. Although it would have been nice to use the former to reduce the number of polygons, the latter works fine with my small polygon set. Perhaps I missed something here, too!

I have enough to probably do the rest of the work geotiff2geotiff-esrishape.fmw using ArcGIS, but I would be curious if there is a better way - which I'm sure there is! I've included my workspace file as reference. Thank you for your time!


@XiaomengAtSafe, thank you for following up with me here and via e-mail! I made the simple error of not knowing how to expose attributes, but I discovered the right-click button on the RasterCellCoercer transformer to expose the values per your instructions. I now have a shapefile with a "band___va" variable name that I've decided doesn't need to go through AttributeManager, since I can always alias the field name on the ArcGIS side.

The new issue is that the "band___va" value is coming across as a float value - but within a text field. Thus I can't use that field for graduated values, since it's not float in the schema. I didn't see a way to convert that field from text to float in a transformer. I can do this with ArcGIS but am surprised that it isn't easier in FME - I must be missing something.

Also, I have to manually edit the exposed attributes in the writer every time I run the workspace and set the values manually to obtain the outputs. I saved the workspace after editing, but once I close and reopen FME and the workspace, the manually set values don't exist, and I have to do them again.

One last "discovery": I was unable to use the RasterToPolygonCoercer because it didn't expose the attributes as the RasterCellCoercer did. Although it would have been nice to use the former to reduce the number of polygons, the latter works fine with my small polygon set. Perhaps I missed something here, too!

I have enough to probably do the rest of the work geotiff2geotiff-esrishape.fmw using ArcGIS, but I would be curious if there is a better way - which I'm sure there is! I've included my workspace file as reference. Thank you for your time!

Hi @pdituri,

 

I did some testing here, hopefully I can address these questions:

 

1. When I expose the list element 0, the new attribute created on the writer in Automatic mode is "_band_0__v". And in this Automatic mode the "_band{0}.value" on the RasterCellCoercer should be linked with the corresponding writer attribute automatically. see screenshot:

 

2. If you open up the writer feature type setting, and go to the User Attribute tab, you should be able to change the mode to Manual, and this will allow you to change the attribute to float type, as you wish:

 

3. I couldn't reproduce the issue where the new attribute on the writer disappears after saving-closing-reopening the workspace. Try again, while using the attribute "_band_0__v", and if that still doesn't work. Maybe download the latest FME here, and see if it solves the problem.

 

4. You are correct that RasterToPolygonCoercer doesn't automatically expose the _label attribute that stores the cell values. You can use an AttributeExposer afterwards to expose it. This is a known issue, and is on our radar to fix.

 

Hope this helps you move a bit further in FME on your workflow. Xiaomeng


Reply