Skip to content

Hazard.from_xarray_raster should read CRS information, if available #1059

@peanutfun

Description

@peanutfun

I tested the Hazard.from_xarray_raster function using daily humidity data (hurs) from DWD EPISODES, which uses the Lambert Conformal Conic projection (EPSG:3034). The data was successfully loaded as a Hazard object with no issues related to the CRS format.

However, by default, the coordinate reference system (CRS) recorded in the object was EPSG:4326, as this is coded in the function’s properties.

Like :
haz.centroids.crs
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:

  • Lat[north]: Geodetic latitude (degree)
  • Lon[east]: Geodetic longitude (degree)
    Area of Use:
  • name: World.
  • bounds: (-180.0, -90.0, 180.0, 90.0)
    Datum: World Geodetic System 1984 ensemble
  • Ellipsoid: WGS 84
  • Prime Meridian: Greenwich_

However, my data properties are: ETRS_1989_LCC, Datum: D_ETRS_1989, Spheroid: GRS_1980, Authority: EPSG:3034, Prime Meridian: Greenwich (0.0), Projection: Lambert Conformal Conic.

Perhaps the function could trigger a warning indicating that the CRS should be manually defined, or (more ambitiously ) try to extract it automatically from the data. However, in my case, this is not straightforward.

For now, I did:

ds = xr.open_dataset("/Users/daraya/Downloads/hurs_day_GCFS21--DWD-EPISODES2022--DE-5_sfc20240601_r1i1p1_20240601-20241130.nc")
intensity_variable = "hurs"
hazard_type = "HU"
intensity_unit = "%"

Create hazard from xarray

haz = Hazard.from_xarray_raster(
data=ds,
hazard_type=hazard_type,
intensity_unit=intensity_unit,
intensity=intensity_variable,
crs="EPSG:3034",
coordinate_vars={
"event": "time",
"longitude": "lon",
"latitude": "lat",

}

) Obviously, with my data I can't use functions like dist_to_coast, which are based on EPSG:4326. I think it's a great idea to have the flexibility to incorporate data with different coordinate systems.

Originally posted by @DahyannAraya in #1020 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions