0

I want to convert a GeoPandas GeoDataframe to raster (.tif). I have multiple attributes in my GeoDataframe and want to create a raster using a single field from the attribute table. The underlying vector format are 16x16m square polygons, which should be represented later by a single pixel.

Up to now I haven't found any straight-forward solutions or useful tutorials, so I qm looking for some helpful answers or hints of where to find practical information.

I'm using Windows 10 and Python 3.8.

3

You may be interested in geocube (https://github.com/corteva/geocube):

Examples: https://corteva.github.io/geocube/stable/examples/examples.html

from geocube.api.core import make_geocube

gdf = geopandas.read_file(...)
cube = make_geocube(vector_data=gdf, measurements=["column_name"], resolution=(16, -16))
out_grid["column_name"].rio.to_raster("my_rasterized_column.tif")

Not the answer you're looking for? Browse other questions tagged or ask your own question.