I have a shapefile that consists of two fields/attributes, one being integers, the other being strings.
I can extract the integers into Python array by first using the function gdal.RasterizeLayer()
to burn the shapefile into a .tiff image as the first band. Then, I use my_raster.GetRasterBand(1).ReadAsArray()
to read the integers as an array.
However, I would like to extract the string values from the other field/attribute. I doing the exact same thing but I have already changed the attribute name in the gdal.RasterizeLayer()
specification. However, calling GetRasterBand(1).ReadAsArray()
only gives me zeros.
Does anyone know whether it is possible to read strings from rasters?
Btw: I'm using the exact same code as here.
Check it out from
Pure Python version -- gdal.RasterizeLayer