I have a .shp file and I would like to convert it into a GEOTIFF. My shape file consists of a large polygon with many polygons inside. I am using the following code, but the output TIF consists of only the large polygon.
from osgeo import ogr, gdal
import subprocess
InputVector = Shapefile
OutputImage = OutputfileName
gdalformat = 'GTiff'
datatype = gdal.GDT_Byte
burnVal = 1
Shapefile = ogr.Open(InputVector)
Shapefile_layer = Shapefile.GetLayer()
Output = gdal.GetDriverByName(gdalformat).Create(OutputImage, RasterXSize, RasterYSize, 1, datatype, options=['COMPRESS=DEFLATE'])
Output.SetProjection(Projection)
Output.SetGeoTransform(GeoTransform)
Band = Output.GetRasterBand(1)
Band.SetNoDataValue(0)
gdal.RasterizeLayer(Output, [1], Shapefile_layer, burn_values=[burnVal])
subprocess.call("gdaladdo --config COMPRESS_OVERVIEW DEFLATE "+OutputImage+" 2 4 8 16 32 64", shell=True)
I am unsure what I am doing wrong here.
Thanks