Skip to main content

Questions tagged [xarray]

xarray is a Python module for working with N-dimensional arrays

1 vote
2 answers
755 views

Add projection to rioxarray dataset in Python

I've downloaded a netcdf from the Climate Data Store and would like to write a CRS to it, so I can clip it for a shapefile. However, I get an error when assigning a CRS. Below my script and what is ...
CrossLord's user avatar
  • 215
0 votes
2 answers
940 views

How to stack list of Xarrays

I have a folder with 4 .tiff (GeoTiff) files. Each of these contains two layers (the spectral band and a mask). I'm able to create a list containig each image using xarray.open_rasterio. Now I need to ...
sermomon's user avatar
  • 994
2 votes
1 answer
5k views

Error trying to open NetCDF file with xarray from s3 bucket

I'm trying to open a .nc file from an S3 bucket using xarray, but I'm getting an error. Here's the method I'm using: import xarray as xr aws_url = 's3://nasanex/NEX-GDDP/BCSD/rcp85/day/atmos/tasmax/...
JWB's user avatar
  • 604
0 votes
1 answer
390 views

Xarray mean for climatologies use min_count as in xarray sum

Why there is not implemented in xr.mean() a parameter for minimum count of valid data accross arrays? As in xr.sum() for example. I have a certain situation where I want to compute climatologies and I'...
George Boldeanu's user avatar
0 votes
1 answer
210 views

Wrong results using xarray groupby to calculte anomalies

I want to compute ten days anomalies based on MODIS NDSI. The data is stored as a GeoTIFF. For this task I have two folders, one with the reference period of 2001-2020 and one with 2001-2022 for which ...
George Boldeanu's user avatar
4 votes
1 answer
4k views

How to save an xarray.DataArray directly as a Cloud Optimized GeoTIFF?

Is there a good way to produce a cloud-optimized GeoTIFF (https://www.cogeo.org) directly from an xarray.DataArray? At the moment it takes me a couple of steps to produce an intermediate regular ...
weiji14's user avatar
  • 1,751
0 votes
1 answer
187 views

Plotting Open Data Cube xarray data with two or more measurement parameters in the same axis

How can I plot the two measurement parameters (seasonal cover and permanent water cover) in the same axis as I want to compare them? I have this code: #load the cgls product ds_cgls_builtcover = dc....
Essy Maina's user avatar
1 vote
1 answer
719 views

Create new column containing values of a xarray variable selected by point coordinates

I have a xarray and a geodataframe. I want to extract spi_1 values of xarray from point geometries of geodataframe by creating a new column spi_1 in geodataframe. print(xr) <xarray.DataArray '...
pyaj's user avatar
  • 175
1 vote
1 answer
2k views

xarray NetCDF with groups to GeoTIFF

I am trying to convert NetCDF files, available from this link, to raster or geotiff files using Python 3. After reading the a NetCDF file using the package netcdf4, it appears to have groups: CO2, ...
Atreya Dey's user avatar
1 vote
0 answers
241 views

Is there a rioxarray version of xarray pad

I have a geocoded raster that I'd like to pad with NaNs to 64 x 64 pixels. I've tested rioxarray.DataArray.pad_box(), which does work, but it's a bit complex to calculate new bounding box corners that ...
user8188435's user avatar
3 votes
1 answer
3k views

Value error when merging .nc files: xarray could not find any dimension coordinates to use to order the datasets for concatenation

I want to merge multiple .nc files into one. Each of the .nc files corresponds to a timestep which should be added together to have one .nc file with all data for all dates. When I execute the ...
ScienceNoob's user avatar
1 vote
2 answers
1k views

rio.write_crs() leaves empty crs

I have a dataset ds which looks like this: <xarray.Dataset> Dimensions: (time: 42, long: 1383, lat: 586) Coordinates: * time (time) datetime64[ns] 1979-01-01 1980-01-01 ... 2020-...
Stefano Potter's user avatar
3 votes
1 answer
2k views

How to add a band to xarray dataset using rioxarray

I have two datasets, both rasters, which I would like to combine into 1 raster. This should not be difficult, but I'm having a hard time.. Both have the same extent/resolution etc. One raster has 231 ...
CrossLord's user avatar
  • 215
0 votes
1 answer
252 views

Transforming GPM Precip Data using rioxarray

I am working with GPM Precip data on a hydrologic study and I am having a hard time figuring out why the netcdf files I downloaded are giving me issues when I try and map the data. I am still learning ...
dubbbdan's user avatar
  • 136
2 votes
1 answer
548 views

How to fix rioxarray.exceptions.DimensionMissingCoordinateError: x missing coordinates?

I'm trying to reproject a NetCDF file without an assigned projection. I was successful in assigning projection. But, while attempting to reproject the file, I receive the following error: rioxarray....
PPR's user avatar
  • 521

15 30 50 per page
1
3 4
5
6 7
9