I'm a bit confused about how to use polygonize (raster to vector). Particularly what to put in the field name box. The documentation states that it

"Defines the field name in which the attributes of the connected regions are entered"

What does this mean?

And what does use mask do? It's not mentioned at all (it seems optional, but I'm still curious)

  • Mask should reduce the output, like a clip. If your raster doesn't have an attribute table then leave this field blank.. integer rasters can have an attribute table which acts as a lookup table for cell values to specific attributes, for example a landuse raster with a cell value of 1 could lookup to the table with a field value 'cropland'; this is important if more than one cell value has the same attribute. – Michael Stimson May 15 '18 at 1:51
  • Aha! If you write your comment as an answer, I'll accept it – Shane May 15 '18 at 1:58
  • If my comment has lead you to an answer feel free to answer your own question with screenshots of your process for the benefit of future users. – Michael Stimson May 15 '18 at 2:00

As you have deduced already the QGIS polygonize utility is a GUI for GDAL_Polygonize which briefly explains the use of a mask:

-mask filename: Use the first band of the specified file as a validity mask (zero is invalid, non-zero is valid). If not specified, the default validity mask for the input band (such as nodata, or alpha masks) will be used (unless -nomask is specified)

It's like putting an alpha mask on a section of the raster, use this option to reduce the extent of polygonization for very large datasets.. you can create a suitable mask from a feature class (eg shapefile) by selecting/exporting area features and rasterizing using GDAL_Rasterize (note: you could also use -l -where ); get the value of [-te xmin ymin xmax ymax] [-tr xres yres] from your existing raster with GDALInfo to ensure extents and cell sizes match.

According to the documentation:

-fieldname The name of the field to create (defaults to "DN").

The use of Fieldname specifies what the output polygon feature class field to store raster values is called, which is converse to the comment I made. The default is DN but if you needed your field called 'ras_value' then populate that field with ras_value. Internal boundaries between cells that have the same value will be removed so that only large polygons remain for each unique value.

Note: It is not specified in the help but only integer rasters (generally) should be polygonized, this is due to the high variation that is normal for float type rasters results in no cell dissolution and can take a very long time and exceed maximum file limits.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.