Open emanuel-schmid opened 3 months ago
hmmm, is the crs not written into the centroids when using the Hazard.from_raster
method (if not explicitly given, it uses the default one)?
Why? Yes. I suppose the problem arises just because the crs is explicitly given but not suitable for plotting (or other meaningful crs handling).
Aaa sorry, I get it know. It is that the crs is not readable by cartopy.
But then the fix should be in setting the correct crs when reading the data no?
I agree.
However:
to_crs
, but only by direct assignmentTherefore I think that our (the Centroids
') to_crs
should actually catch that error and fix it, because we don't want anybody to have to touch the gdf
.
aaa good point!
Starting from climada 5.0, the crs of a Centroids object is bound to its GeoDataFrame (centroids.gdf).
It is possible though to create a Centroids object with an inapt crs by using
Centroids.from_meta
and a crs like, e.g.:This can happen if the hazard object is read from a shp file. (e.g.,
climada_petals.hazard.landslide.Landslide.from_prob
).Any hazard object based on this will behave normally, in general, but plotting (
plot_intensity
) raises an error as well asto_crs
. The only remedy to fix the crs is by directly overwriting it:I think we should possibly fix this in
from_meta
, but at least allow replacing a broken crs with a good one into_crs
.