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.