1

From polygons, I would like to create multiple masks or a single multicolor mask as raster (tif) image.

the source data (if imported using geopandas) has the following columns: zone (values 0, 1, or 2) group (values 0, 1, or 2) group_name ('bad', 'good', 'excellent') geometry (polygons)

I would like to create a tiff file where every group (0, 1, and 2) is represented with its own color (say red, green and blue).

If I try to display the polygons with geopandas, I get the following image:

f, ax = plt.subplots(1)
ax = df_results.plot(ax=ax, column='quality', cmap='OrRd')
ax.set_axis_off()
plt.show();

enter image description here

When imported in qgis, the image looks like this: enter image description here

I tried to run Raster -> Conversion -> Rasterize (Vector to Raster) with the following settings:

enter image description here

This, however, gives the following errors:

QGIS version: 3.20.3-Odense
QGIS code revision: 495fbaecaf
Qt version: 5.12.8
Python version: 3.8.10
GDAL version: 3.0.4
GEOS version: 3.8.0-CAPI-1.13.1 
PROJ version: Rel. 6.3.1, February 10th, 2020
PDAL version: 2.0.1 (git-version: Release)
Processing algorithm…
Algorithm 'Rasterize (vector to raster)' starting…
Input parameters:
{ 'BURN' : 0, 'DATA_TYPE' : 5, 'EXTENT' : '20.299362129,102620.299362129,-102554.693963024,45.306036976', 'EXTRA' : '', 'FIELD' : 'group', 'HEIGHT' : 0, 'INIT' : None, 'INPUT' : '/home/niko/workspace/login5-private/stand_count/data/MU-38-zrenje-StandCount_27991_results/MU-38-zrenje-StandCount_27991_polygons_results.shp', 'INVERT' : False, 'NODATA' : 0, 'OPTIONS' : '', 'OUTPUT' : 'TEMPORARY_OUTPUT', 'UNITS' : 0, 'USE_Z' : False, 'WIDTH' : 0 }

GDAL command: gdal_rasterize -l MU-38-zrenje-StandCount_27991_polygons_results -a group -ts 0.0 0.0 -a_nodata 0.0 -te 20.299362129 -102554.693963024 102620.299362129 45.306036976 -ot Float32 -of GTiff /home/niko/workspace/login5-private/stand_count/data/MU-38-zrenje-StandCount_27991_results/MU-38-zrenje-StandCount_27991_polygons_results.shp /tmp/processing_cfcrYb/e2a0c7f41b254f51a73ca9661b37f028/OUTPUT.tif GDAL command output: /home/niko/anaconda3/bin/gdal_rasterize: error while loading shared libraries: libpoppler.so.71: cannot open shared object file: No such file or directory Process returned error code 127 Execution completed in 0.94 seconds Results: {'OUTPUT': '/tmp/processing_cfcrYb/e2a0c7f41b254f51a73ca9661b37f028/OUTPUT.tif'}

Loading resulting layers The following layers were not correctly generated. • /tmp/processing_cfcrYb/e2a0c7f41b254f51a73ca9661b37f028/OUTPUT.tif You can check the 'Log Messages Panel' in QGIS main window to find more information about the execution of the algorithm.

Beside converting it to the image, I would like to convert it to epsg:4326. Basically, besides the mask, I have an RGB image that I would like to use to train the segmentation model and thus, for every subregion, I would like to have a corresponding mask.

Niko Gamulin
  • 149
  • 5

0 Answers0