Skip to main content
deleted 51 characters in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

I'm currently using the Python module rioxarray to clip an Xarray dataset based on a specific geometry to produce a latitude/longitude grid of coordinates. My data is below:

obs_dataset_full

xarray.Dataset

Dimensions:
Lat: 451 Lon: 350 lat: 450 lon: 350

Coordinates:
Lon
(Lon)
int64
0 1 2 3 4 5 ... 345 346 347 348 349
Lat
(Lat)
int64
0 1 2 3 4 5 ... 446 447 448 449 450
Longitude
(lon)
float64
-105.7 -105.7 ... -78.34 -78.26
Latitude
(lat)
float64
35.04 35.08 35.11 ... 51.52 51.56
spatial_ref
()
int64
0
Data variables:
precip_var
(lon, lat, Lon, Lat)
float64
0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 nan

Attributes:
grid_mapping :
spatial_ref

Note: The Lon/Lat dimensions are irrelevant; I'm trying to utilize the lon/lat, which have the actual coordinates.

obs_dataset_full.rio.write_crs('EPSG:4326',inplace = True)
obs_dataset_cropped = obs_dataset_full.rio.clip(geometries=cropping_geometries, crs='EPSG:4326')

When I run this code, I get the following error:

DimensionMissingCoordinateError: lon missing coordinates.

Both the obs_dataset_fullobs_dataset_full dataset and the precip_varprecip_var data array have the appropriate coordinates assigned to them, the lat/lon grid is filled with evenly spaced values, and the dimensions exist. Unfortunately, the rioxarray documentation page is not particularly clear as to what this exception entails.

Any help is much appreciated; thank you in advance!

I'm currently using the Python module rioxarray to clip an Xarray dataset based on a specific geometry to produce a latitude/longitude grid of coordinates. My data is below:

obs_dataset_full

xarray.Dataset

Dimensions:
Lat: 451 Lon: 350 lat: 450 lon: 350

Coordinates:
Lon
(Lon)
int64
0 1 2 3 4 5 ... 345 346 347 348 349
Lat
(Lat)
int64
0 1 2 3 4 5 ... 446 447 448 449 450
Longitude
(lon)
float64
-105.7 -105.7 ... -78.34 -78.26
Latitude
(lat)
float64
35.04 35.08 35.11 ... 51.52 51.56
spatial_ref
()
int64
0
Data variables:
precip_var
(lon, lat, Lon, Lat)
float64
0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 nan

Attributes:
grid_mapping :
spatial_ref

Note: The Lon/Lat dimensions are irrelevant; I'm trying to utilize the lon/lat, which have the actual coordinates.

obs_dataset_full.rio.write_crs('EPSG:4326',inplace = True)
obs_dataset_cropped = obs_dataset_full.rio.clip(geometries=cropping_geometries, crs='EPSG:4326')

When I run this code, I get the following error:

DimensionMissingCoordinateError: lon missing coordinates.

Both the obs_dataset_full dataset and the precip_var data array have the appropriate coordinates assigned to them, the lat/lon grid is filled with evenly spaced values, and the dimensions exist. Unfortunately, the rioxarray documentation page is not particularly clear as to what this exception entails.

Any help is much appreciated; thank you in advance!

I'm currently using the Python module rioxarray to clip an Xarray dataset based on a specific geometry to produce a latitude/longitude grid of coordinates. My data is below:

obs_dataset_full

xarray.Dataset

Dimensions:
Lat: 451 Lon: 350 lat: 450 lon: 350

Coordinates:
Lon
(Lon)
int64
0 1 2 3 4 5 ... 345 346 347 348 349
Lat
(Lat)
int64
0 1 2 3 4 5 ... 446 447 448 449 450
Longitude
(lon)
float64
-105.7 -105.7 ... -78.34 -78.26
Latitude
(lat)
float64
35.04 35.08 35.11 ... 51.52 51.56
spatial_ref
()
int64
0
Data variables:
precip_var
(lon, lat, Lon, Lat)
float64
0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 nan

Attributes:
grid_mapping :
spatial_ref

Note: The Lon/Lat dimensions are irrelevant; I'm trying to utilize the lon/lat, which have the actual coordinates.

obs_dataset_full.rio.write_crs('EPSG:4326',inplace = True)
obs_dataset_cropped = obs_dataset_full.rio.clip(geometries=cropping_geometries, crs='EPSG:4326')

When I run this code, I get the following error:

DimensionMissingCoordinateError: lon missing coordinates.

Both the obs_dataset_full dataset and the precip_var data array have the appropriate coordinates assigned to them, the lat/lon grid is filled with evenly spaced values, and the dimensions exist. Unfortunately, the rioxarray documentation page is not particularly clear as to what this exception entails.

Source Link

How to rectify rioxarray dimensions missing coordinates

I'm currently using the Python module rioxarray to clip an Xarray dataset based on a specific geometry to produce a latitude/longitude grid of coordinates. My data is below:

obs_dataset_full

xarray.Dataset

Dimensions:
Lat: 451 Lon: 350 lat: 450 lon: 350

Coordinates:
Lon
(Lon)
int64
0 1 2 3 4 5 ... 345 346 347 348 349
Lat
(Lat)
int64
0 1 2 3 4 5 ... 446 447 448 449 450
Longitude
(lon)
float64
-105.7 -105.7 ... -78.34 -78.26
Latitude
(lat)
float64
35.04 35.08 35.11 ... 51.52 51.56
spatial_ref
()
int64
0
Data variables:
precip_var
(lon, lat, Lon, Lat)
float64
0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 nan

Attributes:
grid_mapping :
spatial_ref

Note: The Lon/Lat dimensions are irrelevant; I'm trying to utilize the lon/lat, which have the actual coordinates.

obs_dataset_full.rio.write_crs('EPSG:4326',inplace = True)
obs_dataset_cropped = obs_dataset_full.rio.clip(geometries=cropping_geometries, crs='EPSG:4326')

When I run this code, I get the following error:

DimensionMissingCoordinateError: lon missing coordinates.

Both the obs_dataset_full dataset and the precip_var data array have the appropriate coordinates assigned to them, the lat/lon grid is filled with evenly spaced values, and the dimensions exist. Unfortunately, the rioxarray documentation page is not particularly clear as to what this exception entails.

Any help is much appreciated; thank you in advance!