Question

Transform data from raster to vector and working with attribute-data


Badge

Dear FME-Users,

 

I’d like to transform data from raster to vector (e.g. shapefile) and add attributes. The transformer “RasterToPolygonCoercer” works, but the second one “AttributeCreator” doesn’t add the desired attribute. I’ve already verified the output-shapefile in ArcMap.

 

The second step includes to read and classify attribute-data from raster, classify them by breakpoint and add them to the new attribute.

 

Maybe someone of the community here have ideas and can help me.

 

 

Thank you so much. :)

 

 

Best regards!

15 replies

Userlevel 4

Have you added the attributes introduced in the AttributeCreator in the writer output feature type definition?

Badge

Thank you so much david_r. I’ve done this and it works so far. Now I want to classify the attribute-data with the AttributeRangeMapper. The problem is that the attribute-fields are empty. Maybe somebody knows how to solve this problem?

Thank you so much. :)

Badge

I think I'm also struggling with the same or similar problem. I'm trying to convert what I believe is a single band .tif file into a vector format. I believe the band to have values 0 through 5 i.e. 6 categories. I've used the RasterToPolygonCoercer and this seems to have created polygons of contiguous cells but the attribute value has not been written as I expected (like in the other example @abu_de_bdlq_16 has raised). Presumably there's an additional step that needs to be performed? Any hints gratefully received.

Userlevel 4

Thank you so much david_r. I’ve done this and it works so far. Now I want to classify the attribute-data with the AttributeRangeMapper. The problem is that the attribute-fields are empty. Maybe somebody knows how to solve this problem?

Thank you so much. :)

Can you be a bit more specific? Perhaps post a workspace with sample data or post some screenshots?

 

 

Userlevel 2
Badge +17

I think I'm also struggling with the same or similar problem. I'm trying to convert what I believe is a single band .tif file into a vector format. I believe the band to have values 0 through 5 i.e. 6 categories. I've used the RasterToPolygonCoercer and this seems to have created polygons of contiguous cells but the attribute value has not been written as I expected (like in the other example @abu_de_bdlq_16 has raised). Presumably there's an additional step that needs to be performed? Any hints gratefully received.

Hi @matt_yw, the band value (0-5 in your case) should be saved as an attribute called "_label" by default when you transform the raster into polygons with the RasterToPolygonCoercer. Do you mean that the "_label" will be empty?

 

Badge
Hi @matt_yw, the band value (0-5 in your case) should be saved as an attribute called "_label" by default when you transform the raster into polygons with the RasterToPolygonCoercer. Do you mean that the "_label" will be empty?

 

@takashi Brilliant! I have extracted the "_label" attribute and used AttributeManager to rename it to a better attribute name. I knew it must have been something relatively simple I was missing. Thank you so much for your help and fast answer to my question. I wonder if this is also the issue @abu_de_bdlq_16 is having?
Badge +16
@takashi Brilliant! I have extracted the "_label" attribute and used AttributeManager to rename it to a better attribute name. I knew it must have been something relatively simple I was missing. Thank you so much for your help and fast answer to my question. I wonder if this is also the issue @abu_de_bdlq_16 is having?
You can specify your output attribute name directly in the rastertopolygoncoercer and this way avoid using the attribute manager.

 

 

Badge

I think I'm also struggling with the same or similar problem. I'm trying to convert what I believe is a single band .tif file into a vector format. I believe the band to have values 0 through 5 i.e. 6 categories. I've used the RasterToPolygonCoercer and this seems to have created polygons of contiguous cells but the attribute value has not been written as I expected (like in the other example @abu_de_bdlq_16 has raised). Presumably there's an additional step that needs to be performed? Any hints gratefully received.

Thanks @itay - I've updated the workspace to remove the unnecessary transformer.

Badge

I use NetCDF as reader and ESRI-Shapefile as writer. Following transformer I use:

 

1. RasterToPolygonCoecerer

 

2. AttributeRangeMapper

 

3. AttributeCreator

 

 

The aim is to classify/filter and merge all the data of one attribute. The attribute-data are decimal numbers (e.g. 119.1614). Afterwards I’d like to create several features. I hope it’s specific enough for you @david_r. Congrats @matt_yw that you've got the solution in this thread.

The output file must not be a shapefile.

Thank you so much and best regards. :)

netcdf2shape2.pngnetcdf2shape3.png

Userlevel 2
Badge +17

I use NetCDF as reader and ESRI-Shapefile as writer. Following transformer I use:

 

1. RasterToPolygonCoecerer

 

2. AttributeRangeMapper

 

3. AttributeCreator

 

 

The aim is to classify/filter and merge all the data of one attribute. The attribute-data are decimal numbers (e.g. 119.1614). Afterwards I’d like to create several features. I hope it’s specific enough for you @david_r. Congrats @matt_yw that you've got the solution in this thread.

The output file must not be a shapefile.

Thank you so much and best regards. :)

netcdf2shape2.pngnetcdf2shape3.png

Firstly make sure that the list attribute called "netcdf_data_variable.valid_range{}" contains valid elements. Connect the Inspector to the RasterToPolygonCoercer and run the workspace, then you can see all the attributes of each feature on the Feature Information window of Data Inspector.

 

Then, if you need to save the first element of the list, you will have to expose "netcdf_data_variable.valid_range{0}" and connect it to the destination attribute - "netcdf_dat".

 

See here to learn more about FME list attributes: FME Workbench | About List Attributes

 

Badge

Thank you so much @takashi. I used the Inspector now. The list attribute "netcdf_data_variable.valid_range{}" contains valid elements. They are listed under the attribute "_label" (netcdf2shape3.png). But the elements are not classified as expected. The attribute "_looked_up" is still empty.

Userlevel 4

Thank you so much @takashi. I used the Inspector now. The list attribute "netcdf_data_variable.valid_range{}" contains valid elements. They are listed under the attribute "_label" (netcdf2shape3.png). But the elements are not classified as expected. The attribute "_looked_up" is still empty.

How is "_looked_up" defined in the feature class (data type)? It should probably be a varchar(20) or something similar.

 

 

Are there any warnings in the FME log about dropped features? Click inside the log window, press Ctrl-F and look for "WARN".

 

Badge +16

Thank you so much @takashi. I used the Inspector now. The list attribute "netcdf_data_variable.valid_range{}" contains valid elements. They are listed under the attribute "_label" (netcdf2shape3.png). But the elements are not classified as expected. The attribute "_looked_up" is still empty.

You can also define a default value in the value mapper.

 

 

Badge

The feature data type is defined as char (20). Other possibilities are date, logical and number. I’ve tried also number without success. There’s following warning at 3 times again: “NETCDF reader: No UNIDATA NC_GLOBAL:Conventions attribute”. I’ve processed raster data before with success. I think this doesn’t matter. netcdf2shape4.png

I’ve tried the ValueMapper with default value. Now it’s necessary to classify the attribute data from _label. netcdf2shape5.png

 

Thank you so much @david_r and @itay !:)

Badge

Now it works with the Transformer AttributeRangeFilter. Thanks to all of you for helping me!

Reply