I'm currently using this code to convert a raster file to a geodataframe:
import rasterio
from rasterio.features import shapes
mask = None
with rasterio.open(#INSERT TIF FILE HERE) as src:
image = src.read(1) # first band, not sure yet how to do it with multiple bands
results = (
{'properties': {'raster_val': v}, 'geometry': s}
for i, (s, v)
in enumerate(
shapes(image, mask=mask))) geoms = list(results)
import geopandas as gpd
gpd_polygonized_raster = gpd.GeoDataFrame.from_features(geoms)
The problem is, the geodataframe is showing upside down instead of its expected oreintation.
Any help on this would be appreciated. Thank you!
Take note that the TIFF file has a projection already of EPSG:4326.