1

I have two xarray data arrays (1. land_data, 2. climate_data) that I want to reproject and match (rio.reproject_match()):

climate_data_matched = climate_data.rio.reproject_match(land_data)
  1. Land data is a geotiff file with land_data.rio.crs = EPSG:4326. The crs attribute is accepted by rio.reproject_match().
  2. Climate data is a netcdf file with climate_data.rio.crs =

GEOGCRS["undefined",BASEGEOGCRS["undefined",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ID["EPSG",6326]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],DERIVINGCONVERSION["Pole rotation (netCDF CF convention)",METHOD["Pole rotation (netCDF CF convention)"],PARAMETER["Grid north pole latitude (netCDF CF convention)",39.25,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],PARAMETER["Grid north pole longitude (netCDF CF convention)",198,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],PARAMETER["North pole grid longitude (netCDF CF convention)",0,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]],CS[ellipsoidal,2],AXIS["longitude",east,ORDER1,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],AXIS["latitude",north,ORDER2,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]]

However, rio.reproject_match() does only support OGC WKT (from spatialreference.org).

PROBLEM: If I run the code as described above, the climate_data array is empty (NaN values).

My assumption is that the prefix GEOGCRS cannot be interpreted and instead I need to convert the wkt to a string starting with GEOGCS (in line with OGC WKT). How can I convert them? I converted crs = climate_data.rio.crs.to_proj4() and then wanted to use pycrs to crs = pycrs.parse.from_proj4(crs) and crs = pycrs.parse.from_ogc_wkt(crs). But I got an error parsing the proj4 string: "The specified projection name 'ob_tran' could not be found in the list of supported projections."

If I manually modify the crs of climate_data climate_data = climate_data.rio.write_crs("epsg:4326", inplace=True) and then run the code from above rio.reproject_match() works perfectly fine. But I do not know whether 'EPSG:4326' is actually to right code for the climate_data. How can I get the EPSG code from the wkt string starting with GEOGCRS?

Furthermore, I found this issue that proj4 failed in the past with GEOGCRS. And GEOGCRS is also defined in opengeospatial.org.

3
  • Maybe you should update the reading program. The WKT standard says "If the WKT begins with or contains any of the following keywords, it is an older format: COMPDCS, FITTED_CS, GEOCCS, GEOGCS, LOCAL_CS, PROJCS, VERT_CS. The last characters in all these keywords are 'CS'."
    – user30184
    May 15 at 19:37
  • Can you edit your question to include the full WKT string please
    – user2856
    May 15 at 21:00
  • 1. The land data is an EPSG code and the climate data is contains the keyword GEOGCRS. so it seems that it is not an older format. 2. I added the full WKT. Maybe FYI: The climate data was a rotated grid data I changed to a regular grid. But I did not change the CRS attribute.
    – ProgMau
    May 16 at 21:13

1 Answer 1

2

Looks like "Pole rotation (netCDF CF convention)" was added in PROJ 8.2:

Requires PROJ >= 8.2 to work. So, you need to have your version of pyproj/GDAL built against PROJ >= 8.2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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