Skip to main content
Question

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


Forum|alt.badge.img

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

david_r
Celebrity
  • October 26, 2016

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


Forum|alt.badge.img
  • Author
  • October 27, 2016

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. :)


mappymatty
Contributor
Forum|alt.badge.img+3
  • Contributor
  • October 27, 2016

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.


david_r
Celebrity
  • October 27, 2016
uba_kp wrote:

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?

 

 


takashi
Influencer
  • October 27, 2016
mappymatty wrote:

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?

 


mappymatty
Contributor
Forum|alt.badge.img+3
  • Contributor
  • October 27, 2016
takashi wrote:
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?

itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • October 27, 2016
mappymatty wrote:
@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.

 

 


mappymatty
Contributor
Forum|alt.badge.img+3
  • Contributor
  • October 27, 2016
mappymatty wrote:

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.


Forum|alt.badge.img
  • Author
  • October 27, 2016

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


takashi
Influencer
  • October 27, 2016
uba_kp wrote:

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

 


Forum|alt.badge.img
  • Author
  • October 28, 2016

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.


david_r
Celebrity
  • October 28, 2016
uba_kp wrote:

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".

 


itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • October 28, 2016
uba_kp wrote:

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.

 

 


Forum|alt.badge.img
  • Author
  • October 28, 2016

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 !:)


Forum|alt.badge.img
  • Author
  • November 2, 2016

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings