You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using rasterstats and its zonal statistics where the output of everything is a GeoPandas GeoDataFrame containing the results. I am doing the following as shown below. However, the list of dicts (geojson-like) that zonal_stats returns does not contain the CRS information of the vector data and in return, a GeoDataFrame is created without CRS.
I would like to propose adding the CRS information to the output of zonal_stats so that GeoPandas can create a GeoDataFrame with a valid CRS from it. I could of course just open the vector data using GeoPandas but I like the way it is accomplished below.
I could try working on a PR if that feature is desired for rasterstats.
stats=zonal_stats("path_to_vector.shp",
"path_to_raster.tif",
stats="count min mean max median sum std",
geojson_out=True)
gdf=gpd.GeoDataFrame.from_features(stats)
A place to add the CRS would be somewhere in the fiona_generator, I guess:
Hello,
I am using rasterstats and its zonal statistics where the output of everything is a GeoPandas GeoDataFrame containing the results. I am doing the following as shown below. However, the list of
dicts
(geojson-like) thatzonal_stats
returns does not contain the CRS information of the vector data and in return, a GeoDataFrame is created without CRS.I would like to propose adding the CRS information to the output of
zonal_stats
so that GeoPandas can create a GeoDataFrame with a valid CRS from it. I could of course just open the vector data using GeoPandas but I like the way it is accomplished below.I could try working on a PR if that feature is desired for rasterstats.
A place to add the CRS would be somewhere in the
fiona_generator
, I guess:python-rasterstats/src/rasterstats/io.py
Lines 35 to 38 in 5dac003
The text was updated successfully, but these errors were encountered: