I have a shapefile that looks like the follows:
And here's how the attribute table looks like:
I'm trying to rasterize it with a reference raster and my code is as follows:
input_vector = city_mobile_dir
output_raster = f'../../../data/world_statistics/output_data/city_mobile_gdf_{net}_{iso}.TIF'
ref_raster = f'{source}/world_pop/jpn_ppp_2019_UNadj.tif'
raster_df = gdal.Open(ref_raster, gdal.GA_ReadOnly)
vector_driver = ogr.GetDriverByName('ESRI Shapefile')
vector_df = vector_driver.Open(input_vector, 0)
vector_layer = vector_df.GetLayer()
# fetch number of rows and columns
ncol = raster_df.RasterXSize
nrow = raster_df.RasterYSize
fetch projection and extent
proj = raster_df.GetProjectionRef()
ext = raster_df.GetGeoTransform()
create the raster dataset
memory_driver = gdal.GetDriverByName('GTiff')
out_raster_df = memory_driver.Create(output_raster, ncol, nrow, 1, gdal.GDT_Byte)
set the ROI image's projection and extent to our input raster's projection and extent
out_raster_df.SetProjection(proj)
out_raster_df.SetGeoTransform(ext)
fill our output band with the 0 blank, no class label, value
band = out_raster_df.GetRasterBand(1)
band.SetNoDataValue(-9999)
band.FlushCache()
rasterize the shapefile layer to our new dataset
status = gdal.RasterizeLayer(out_raster_df,
[1],
vector_layer,
None, None,
[0], # burn value 0
['ATTRIBUTE = FID'])
if status != 0:
print("Failed")
else:
print("Success")
But no matter what I tried, I kept getting an entire black tiff. I looked through other similar problems on the website but their solutions don't work on mine either. Unfortunately I'm new to GDAL so I might not have been able to identify the mistake I made in my code.

