Questions tagged [xarray]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
28 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
  • 307
0 votes
0 answers
75 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
84 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
0 votes
0 answers
20 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
39 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
87 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
72 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
0 votes
0 answers
20 views

Incorrect longitude coordinates on NetCDF from CAMS it can't allow masking

I've downloaded from Copernicus Atmosphere Monitoring Service some analysis about particulate matter in .nc file format. I need to mask that data and save in the same file format. Using Xarray library ...
MaxDragonheart's user avatar
0 votes
0 answers
93 views

NetCDF time variable is missing a 'units' attribute

I have NetCDF files whose dates range from Jan 1850 to Dec 2014 (15th of each month). I need to extract data post Jan 1995. I am doing this: start_time = datetime.datetime(1995, 1, 10, 0, 0) times = ...
goaroundmsp's user avatar
1 vote
0 answers
88 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:...
goaroundmsp's user avatar
0 votes
0 answers
182 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
430 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
241 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
98 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
180 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
353 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
376 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
140 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
  • 524
0 votes
0 answers
225 views

Clipping an xarray dataset with rio clip function produces empty xarray

I have an xarray dataset ds containing a variable 'pop'. xarray.Dataset Dimensions: time: 1latitude: 5751longitude: 13197 Coordinates: time (time) datetime64[ns] 2000-12-31 latitude (latitude) float64 ...
Code_Pi's user avatar
0 votes
0 answers
82 views

Interpolating a regular lat/lon grid with latitude line at Equator to a shifted grid using Python

I am very new to GIS and have to work with some precipitation data contained in two different datasets with comparable coordinate systems, but differently offset/shifted coordinates: NASA GPM IMERG ...
bgospodinov's user avatar
0 votes
1 answer
479 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
189 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
  • 270
0 votes
1 answer
169 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
371 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
0 votes
0 answers
163 views

y dimension not found while converting NetCDF to Raster with rasterio

So I have a NetCDF file from the TROPOSIF website and converted it to xarray dataset that looks like this: And I'm trying to convert it to a tif file but while I'm trying to export the SIF_735 ...
Rezwan's user avatar
  • 149
0 votes
0 answers
80 views

Legend for gridded Holoviews visualization with categorical data

I'm using the holoviews extensions to visualize a gridded dataset with landcover classes. Plotting the data is straightforward with da.hvplot(). This results however in a continuous colormap with ...
sir_olf's user avatar
  • 71
0 votes
0 answers
208 views

Using xarray and rioxarray for converting netCDF to GeoTIFF gives TypeError: cannot pickle '_thread.lock' object

I am trying to convert a netCDF file to GeoTIFF file using xarrray and rioxarray. But when I give the rio.to_raster command, it throws the TypeError: cannot pickle '_thread.lock' object. The NetCDF ...
Pradeep S's user avatar
1 vote
0 answers
134 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
369 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
296 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
0 answers
222 views

Zonal stats from NetCDF for all time dimensions

I use the following code to get zonal stats of data for each time. import xarray import rasterstats import geopandas import numpy as np nc_data = xarray.open_dataset(nc_file_path) shp_prj = geopandas....
d.b's user avatar
  • 63
0 votes
1 answer
71 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
39 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
  • 13
1 vote
1 answer
137 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
  • 524
0 votes
1 answer
595 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
  • 115
0 votes
0 answers
27 views

Rasterising GOES-R Derived Motion Winds

I have CONUS Derived Motion Winds netCDF data from the GOES-R 17 satellite, retrieved from the AWS repository (specifically OR_ABI-L2-DMWC). I am trying to rasterise this into a GeoTiff (specifically ...
Soren Saville Scott's user avatar
1 vote
1 answer
218 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.4k
4 votes
0 answers
69 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
225 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
  • 481
0 votes
1 answer
1k views

Xarray computing of a new variable on the basis of the existing one

I have netcdf file with calculated average temperature (°F). My goal is to create new data variable within the same file with cooling / heating degree days using that average. This format is totally ...
nomad_gis's user avatar
0 votes
1 answer
56 views

NetCDF stretched along Y (latitude) axis

I'm working with NOAA temperature NetCDF files and trying limit area of interest to the US area only using bounding box. In Jupyter Notebook I wrote few lines to do it and on the plot everything looks ...
nomad_gis's user avatar
0 votes
1 answer
2k views

Create one NetCDF file from multiple NetCDF files using Python [closed]

I am downloading climate data in NetCDF format. For each variable (e.g. 'precipitation'), I need to merge 9 NetCDFs, each belonging to an unique climate model. Each NetCDF has the same size (time, lat,...
CrossLord's user avatar
  • 215
1 vote
1 answer
1k views

How to deal with Nan value when using rioxarray rio.reproject()?

I was trying to use rio.reproject_match() to match the resolution of two xarray datasets. However, when I used resample methods like Resampling.bilinear or Resampling.average, a large area would ...
QRW's user avatar
  • 33
1 vote
0 answers
216 views

Pixel-based regression using xarray has incorrect P-value, but everything else is correct

I am using the code from this website to perform a regression on each pixel of an image time-series of rain and NDVI. The code works for everything, that is the outputs match the outputs of scipy, for ...
SoupBones's user avatar
2 votes
1 answer
434 views

Convert GeoTIFF to Zarr Store using Xarray

I am trying to convert my 3-band GeoTIFF to Zarr store. I am able to read in the GeoTIFF from xarray with rasterio backend. In [1]: import xarray as xr In [2]: xtci = xr.open_dataset('tci.tif', ...
Aman Bagrecha's user avatar
0 votes
0 answers
533 views

Combine two raster datasets from different areas - xarray

I simply wish to combine two raster datasets from different spatial extents and with different coordinate reference systems using python. Eventually, I wish to combine enumerable datasets, but ...
Sean Carter's user avatar
1 vote
1 answer
1k views

Xarray Dataset to raster - ValueError: failed to prevent overwriting existing key grid_mapping in attrs

I have a netcdf file located here http://thredds.northwestknowledge.net:8080/thredds/catalog/TERRACLIMATE_ALL/data/catalog.html?dataset=TERRACLIMATE_ALL_SCAN/data/TerraClimate_tmin_1958.nc. I am ...
Stefano Potter's user avatar
1 vote
1 answer
1k views

Increase map size with subplots and Cartopy

I try to make subplot maps with Cartopy using data from xarray tutorial and increase each map in vertical size, but failed. Also making colorbar at each specific subplots. import matplotlib.pyplot as ...
Tuyen's user avatar
  • 209
2 votes
1 answer
308 views

Unable to convert Sentinel-5P NetCDF file to GeoTIFF using xarray python

I am trying to convert Sentinel-5P NetCDF file (available at https://drive.google.com/file/d/1dJdhQspdI3p5YyyiBBiNxUPCCOU91QrU/view?usp=sharing) to GeoTIFF using the following code: import xarray ...
RRSC NGP's user avatar
  • 606
0 votes
1 answer
890 views

Why do rioxarray reprojection and pyproj transform give different values when selecting a pixel by point coordinates?

I'm opening this grib file using rioxarray and reprojecting to WGS84 in the following manner with the goal of grabbing pixel values by coordinates. import rioxarray url = 'https://noaa-hrrr-bdp-pds....
JWB's user avatar
  • 524