Skip to main content

Questions tagged [xarray]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
22 views

Earth Engine client library not initialized when using a dask cluster and xarray?

I'm trying to test running a simple math operation client-side using xee, an xarray extension for the Google Earth Engine API. When I set up the Dask client and run the compute() method I keep getting ...
Adriano Matos's user avatar
0 votes
0 answers
26 views

xee: Total request size (56623104 bytes) must be less than or equal to 50331648 bytes

I am using xee, an extension of xarray to work with data from Google Earth Engine. I am trying to test computing NDVI through an xarray of Landsat imagery, but I keep getting this error. EEException: ...
Adriano Matos's user avatar
2 votes
1 answer
27 views

Create .nc file from multiple tif files : metadata time

I'm trying to create a single .nc file with 3 dimensions : x,y and time. In order to do so I have multiple tif files named by their date : 2013-04-24_Turb.tif for the 24-04-2013. I would like to do ...
Aurélien Lengrand's user avatar
1 vote
0 answers
28 views

All-NaN slice encountered when apply xr_phenology function?

I want calculate vegetation phenology from ndvi netcdf dataset, I follow yours tutorials (DEA Australia and DEA Africa) to apply xr_phenology function , defined here. To avoid killed kernel of my ...
tazrart's user avatar
  • 169
0 votes
1 answer
21 views

Invert latitude of NetCDF in Python / xarray

I thought it would be straight up, but I don't find a question like this one here. I created a NetCDF out of a GeoTIFF, but it did not have coordinates or CRS. I added it doing this: coords = { 'time' ...
ImanolUr's user avatar
  • 1,102
0 votes
0 answers
52 views

rioxarray.open_rasterio() won't close a file when using it with a context manager

I am writing some unit tests to test reading in raster data into an xr.Dataset data structure via the rioxarray.open_rasterio() method. The code creates a test raster to read into rioxarray....
Adriano Matos's user avatar
0 votes
0 answers
55 views

Performance difference between xarray open_mfdataset and open_dataset

I'm dealing with CMIP6 Scenariomip data, I have eight ESMs precipitation grid that each one is composed by multiple netcdf files. There is one ESMs's netcdf files are seperately reserved every decade, ...
孟泽楷's user avatar
0 votes
0 answers
91 views

Low performance when writing a large xarray.DataArray with dask

I'm preprocessing HMASR data, the data contains multiple data files with format of netcdf, and each tile (1X1 degree) is a nc file. So I read it through xarray open_mfdataset() to mosaic it spatially ...
孟泽楷's user avatar
1 vote
1 answer
63 views

While exporting the rasters using rioxarray, nodata value is undefined after the mask

I have used xarray to open the netcdf file, and using rioxarray exported the raster as a .tif file. However, the exported raster doesn't have definition for nodata value, and hence, the GIS software ...
hillsonghimire's user avatar
0 votes
1 answer
235 views

AttributeError: 'Dataset' object has no attribute 'rio' when using a LocalCluster from dask.distributed

I am trying to parallelize a function that uses a zarr datacube read from an s3 bucket to perform some calculations. However, when using a LocalCluster from dask.distributed, I lose the .rio accessor ...
LaserGlaciers's user avatar
0 votes
0 answers
97 views

xarray : no such file directory

I'm trying to transform a .nc file in .tiff using this code : import xarray as xr import rioxarray as rio nc_file = xr.open_dataset("C:/Users/aurel/OneDrive/Documents/Mémoire/Datasets/CCI_lake/...
Aurélien Lengrand's user avatar
0 votes
0 answers
48 views

How can I extract the array indices from a xarray.rio.clip operation?

I have a line of code that clips a Dataset from a larger xarray.core.dataset.Dataset. clipped = ds.rio.clip([user_polygon], crs=4326, all_touched=True) I need to process many of these large datasets (...
John's user avatar
  • 141
1 vote
0 answers
22 views

Buffer Error when using xarray

When I tried to using python package "xarray" to read grib files, I got an error. It's quite weird, because I had did it successfully yesterday. This is my code: import xarray as xr import ...
qingsong's user avatar
0 votes
1 answer
44 views

Gridworkflow intersection with other spatial objects such as a geodataframe

I am working with a large GridWorkFlow object; I am not able to load all the tiles due to in-memory compute resources (24.00 GB mem 8 CPU) and do not need to either. I am interested in intersecting ...
rnnnn200333's user avatar
3 votes
1 answer
303 views

How to write CRS info to NetCDF in a way QGIS can read? (Python/Xarray)

I have a NetCDF file I have subset by geometry and time, and now I need to save it as a new NetCDF file. The original file does not have the CRS set, thus I am setting it in this one. The problem is ...
MKF's user avatar
  • 571
0 votes
1 answer
56 views

QGIS crashes with "bad_alloc" when processing NetCDF file using xarray

I need to merge multiple NetCDF files in a QGIS plugin I am developing. I'm using xarray to do so, however, QGIS crashes with the error "Critical: Caught unhandled std::exception: std::bad_alloc&...
Francis Lapointe's user avatar
0 votes
0 answers
31 views

Change dtype of coordinates NetCDF

I was wondering how to change the dtype from float32 to float64 of coordinates. I can run the following code in the terminal ncap2 -s 'lat=double(lat); lon=double(lon)' infile.nc outfile.nc How ever ...
sss's user avatar
  • 1
0 votes
1 answer
242 views

Transform ee.ImageCollection to xr.Dataset in Python (via Colab)

I am trying to transform an ee.ImageCollection (Landsat) for a Region of Interest into an xr.Dataset so I can further process the data and ultimately export as a .csv. I have tried using the library ...
richard.turner's user avatar
0 votes
1 answer
487 views

Extract nearest values from NetCDF file in Python

I have a NetCDF database (link to file) obtained from Copernicus Climate Data of ~43k unevenly spaced values around the world. Instead of being indexed using (lat, lon) it uses a sequence of 'stations'...
terauser's user avatar
0 votes
0 answers
43 views

How to open NetCDF4-CF files from SMAP in xarray

I've downloaded a list of netCDF4-CF files from SMAP (Following this guide in jupyter notebook) to get daily soil moisture data over 2020 in South Sudan. The result is a series of .nc files that I ...
Nick Slanec's user avatar
1 vote
0 answers
96 views

Landsat from Planetary Computer unexpectedly turns up all no data in some regions

Using some code that gathers Landsat 8 collections from Microsoft Planetary Computer into Open Data Cube xarray using a stac search works fine in some regions but in others returns all nan values. ...
jeremyg19's user avatar
  • 317
0 votes
0 answers
257 views

Randomly sample locations from a large xarray dataset

I want to create random sample locations on land (lat/lon), weighted by latitude, from a large xarray dataset. Currently, I am creating the lat/lon pairs from a land-sea-mask with the script below, ...
Felix's user avatar
  • 11
1 vote
0 answers
360 views

Loading geospatial datasets with rioxarray

I'm using xarray to open and reproject some .grib files. The files have x, y, and time dimensions and contain several data variables. However, I have some issues with loading the data. Loading them ...
Felix's user avatar
  • 11
-1 votes
1 answer
48 views

Extending raster after rasterizing geodataframe using geocube

I have created rasterized a geodataframe using geocube make_geocube. The resulting xr.Dataset now has the extent of the underlying geodataframe vector data. Say, the bounding box would be covering ...
ChipChap's user avatar
0 votes
1 answer
75 views

GeoTIFF from Dataset is very weight and with three bands instead of one

I need to compute the NDVI from an xarray Dataset created using this solution. I've used a for loop to read all the GeoTIFFs in my folder and the result is this: <xarray.Dataset> Dimensions: ...
MaxDragonheart's user avatar
0 votes
1 answer
317 views

Memory filled with Xarray concat function

I'm facing in trouble related to the limit of my RAM. On my PC I have 32GB of RAM that is totaly filled from the concat of some DataArray. I've create e simple function below to read a single band of ...
MaxDragonheart's user avatar
1 vote
1 answer
188 views

Using Python (in Colab), how to convert a multiband ee.Image into an ee.ImageCollection?

I ultimately want to convert an ee.Image to an xarray object so I can further process the data. I know the library wxee can do that with ee.ImageCollection.wx.to_xarray(). However, it requires an ee....
Camila's user avatar
  • 21
1 vote
0 answers
152 views

Saving extracted array into new NetCDF file

I have a NetCDF file which looks like this: <xarray.Dataset> Dimensions: (time: 180, d2: 2, lat: 180, lon: 360) Coordinates: * time (time) object 2000-01-15 12:00:00 ... 2014-12-15 12:...
gis_grad_student's user avatar
0 votes
0 answers
347 views

Using rioxarray clip_box function does not return anything

I am trying to clip an xarray dataarray (or dataset, either one) to a bounding box using the rioxarray clip_box() function. My dataarray is 24 hours of temperature data for the continental US. My ...
yeet_man's user avatar
1 vote
1 answer
1k views

Interpolate irregularly sampled data to a regular grid

I'm using .nc files with spatially referenced timeseries data in xarray, i.e. inherently 3-dimensional data (lat, lon, time). My issue is, that the dataset's coordinates lat and lon are merged to a ...
Jonny32418's user avatar
0 votes
1 answer
542 views

Saving plot from .nc file without showing the plot

I am trying to save the sequence of plots of 24 hours of ERA5 data from .nc file without plotting them. I am using xarray for reading .nc data. Here is my code: import xarray as xr import matplotlib....
pwnkit's user avatar
  • 17
1 vote
0 answers
152 views

Convert the netcdf file to geotiff with chosen coordinate system

I have a nc file retrieved from the following link https://www.globsnow.info/swe/nrt/2020/data/GlobSnow_SWE_L3A_20200110_v.1.0.nc.gz. I am trying to convert this file to geotiff in wgs 1984 coordinate ...
srinivas's user avatar
  • 163
0 votes
1 answer
355 views

Error reading variables from NetCDF file with Xarray when there are multiple variable layers

I get an error reading variables from NetCDF file with Xarray when there are multiple variable layers Data: The netCDF file that I have has multiple layers: /Geophysical_Data/...
raraki's user avatar
  • 91
1 vote
2 answers
938 views

Fixing the flipped/inverted Y axis in the xarray with rasterio

The data I read with xarray with rasterio engine is inverted along Y axis (This is SMAPL4 data). The correct dimension values are y=ds.y*(-1). ds = xr.open_mfdataset(file_paths, engine="rasterio&...
raraki's user avatar
  • 91
2 votes
2 answers
994 views

Is it possible to change a coordinate in an netCDF loaded with xarray?

I have a netCDF which is loaded in xarray with a dimension named bands (it was originally an import via rioxarray of ENVI data), but actually, I want to be able to parse the data by time. I have tried ...
Ricardo Barros Lourenço's user avatar
0 votes
1 answer
228 views

When i save my xarray DataAarray the coordinates are wrong

I have three 3x3 arrays that are downsampled data from NOAA's Global Hydro Estimator (smaller to make it quicker for testing). One array is lats, one is lons, and one is rainfall. Here's a sample lons:...
JWB's user avatar
  • 604
0 votes
1 answer
787 views

Convert a multiband GeoTIFF to a timeseries NetCDF file in xarray

I am trying to create a time series object from extracted climate data (NEX-GDDP) using the Google Earth Engine (GEE). The data is daily meteorological data, and in the attached file, the data for ...
Gijs van den Dool's user avatar
1 vote
0 answers
315 views

How to add additional bands to a TIFF using rioxarray

I'm trying to work out how to open a raster, determine the name of the existing band(s), then use that bands value in math to create a new band. I believe the data is being loaded to a DataArray. I'm ...
anakaine's user avatar
  • 290
0 votes
1 answer
296 views

Save multiple GeoTIFF files from a GRIB file, one file per day (time dimension)

I am trying to save multiple GeoTIFF files from a GRIB file I have elaborated. Before converting to raster, the GRIB file I started with is a ERA5 2m hourly temperature over 3 days: import iris # ...
capocchione's user avatar
1 vote
1 answer
724 views

Mask NetCDF data in Python with shapefile

Precursor to this question: Masking NetCDF data with a shapefile in that has more than one variable Python. Note: Data files are in the previous question. I am trying to mask my polygon but I don't ...
Julius Bamah's user avatar
1 vote
0 answers
270 views

Georeference NetCDF using rioxarray

I have a NetCDF file with a lot of variables and an improperly set georeference. Loading using xarray works, using rioxarray.open_rasterio I get the following error: "NotGeoreferencedWarning: ...
lisa's user avatar
  • 11
2 votes
0 answers
506 views

Create an xarray dataset form a series of GeoTIFFs and clipping problem

I am trying to create a dataset from a series of GeoTIFFs (one .tiff file per day) and then clip it with a given geometry (shapefile). The TIFF files, one per day, have this format: e.g. day 29-07-...
capocchione's user avatar
0 votes
1 answer
432 views

Extract data for aoi from preprocessed Landsat CCDC ImageCollection using GEE Python API

I try to extract for a collection of 1 ha square polygons the bands coefficients from a preprocessed Landsat CCDC Google Earth Engine Asset ee.ImageCollection('projects/CCDC/v3'). My plan is the ...
TmtStss's user avatar
  • 23
0 votes
1 answer
102 views

GeoServer Java error when adding layer from NetCDF based store

Using xarray I have subsetted surface current data from the https://resources.marine.coperncus.eu OPeNDAP server. I save the subset as a NetCDF4 file. I am able to add the NetCDF file as a store in ...
Matt's user avatar
  • 11
0 votes
0 answers
49 views

Python, colorize raster randomly avoiding same color for adjacent cells

I'm processing GeoTIFF rasters with python and xarray. The file contains some cells with different values. It looks like that: There are about 100 different values in the file and each value needs to ...
riuss's user avatar
  • 15
2 votes
1 answer
234 views

Is there a way to limit the distance of rioxarray's interpolate_na()

I'm trying to run something similar to gdal's fillnodata command line tool in Xarray. Xarray has interpolate_na() that comes with an optional parameter limit where you can limit the number of ...
JWB's user avatar
  • 604
1 vote
1 answer
1k views

Add lat and lon to DataArray read in by rioxarray

I downloaded a GeoTIFF from here: https://www.nass.usda.gov/Research_and_Science/Crop_Progress_Gridded_Layers/index.php (file also available: https://drive.google.com/file/d/1XcfEw-...
Rafael's user avatar
  • 125
1 vote
1 answer
386 views

Changes to GDAL NetCDF driver between 3.2 and 3.4

I am preparing data in python using xarray and rioxarray, then exporting to NetCDF. On one machine with micha@RMS:Kinneret$ gdalinfo --version GDAL 3.2.2, released 2021/03/05 the extent of the ...
Micha's user avatar
  • 15.7k
4 votes
0 answers
76 views

Looking up whole time-series for specific point from 45 GB file

I want to look-up 8760 times for a single lat/lon combo in less than a second from 43.82 GB file of wind data containing: 8760 times (every hour in a year) 721 latitudes (every 0.25° from -90.0° to ...
user212905's user avatar
0 votes
1 answer
315 views

How to apply a function on two rasters in Python?

I would like to cell-wise function operation on two rasters. While I saw some examples of adding or subtracting two rasters, I'm yet to come across a complex example of how to manipulate rasters using ...
PPR's user avatar
  • 511