[Qgis-user] raster to polygons conversion with float value pixels

Nicolas Cadieux njacadieux.gitlab at gmail.com
Tue Nov 9 06:15:40 PST 2021


Hi,
Not sure we have access to this in QGIS but the raster to vector is based on the polygonize() function in Gdal.  I see they have a fpolygonize() function also that you can call with a python script.  The « f » stands for float.

https://gdal.org/python/index.html

You could probably easily adapt the script found on the Gdal cookbook page.

https://pcjericks.github.io/py-gdalogr-cookbook/raster_layers.html#polygonize-a-raster-band

Nicolas Cadieux
https://gitlab.com/njacadieux

> Le 9 nov. 2021 à 07:22, Bo Victor Thomsen <bo.victor.thomsen at gmail.com> a écrit :
> 
> 
> Greetings list -
> 
> I have a question about polygonization of a raster layer/file with float values as pixel values
> 
> My raster layer  contains pixel float-values from -0.97 to +4.78. When I run the "Polygonize (raster to vector)" processing algorithm I get a new layer with nice polygons in the layer. However, all my depth values has been converted to integers in the range from 0 -  4. And the polygons has been dissolved in fewer and larger polygons that what I wanted.
> 
> Is there a method i.e some qualifier or whatnot, that I can add to the GDAL command-line that would classify the decimal values from meters to  centimeters, i.e I would get a polygon layer with depth values like -0.99, -09.98 ... 4.78 (around 577 discrete values), and a larger number of smaller polygons ?
> 
> I'm aware that I could take the raster layer, multiply the pixel values with 100.0; convert to integer; create the the polygon layer from the modified raster layer and lastly update the depth value in the polygon layer by dividing it with 100. And yes, I can make a processing model to do the work 
> 
> But alas, I have hundreds of raster layers to process, so I trying to minimize the work for processing each of these raster files. 
> 
> 
> 
> 
> 
> -- 
> Med venlig hilsen / Kind regards
> 
> Bo Victor Thomsen
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20211109/cb69679b/attachment.html>


More information about the Qgis-user mailing list