Questions tagged [xarray]

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

Filter by
Sorted by
Tagged with
6
votes
1answer
3k views

xarray slicing across the antimeridian

I'm just starting with using xarray for working with n-dimensional NetCDF datasets. I particularly like the techniques for slicing using both indexes and labels (isel and sel): import xarray as xr ds ...
6
votes
1answer
791 views

Extracting data within geometry (shape)

I have a NetCDF dataset which I normally call using the xarray function. I have recently been doing some transect analysis on the dataset, which looks something like this (the area between the ...
5
votes
1answer
578 views

GDAL crashes with segmentation fault when trying to open a NetCDF subdataset with time dimension

I am trying to create a NetCDF file which is compliant with the NetCDF Conventions CF-1.4. The dimensions of the file are (TIME, Y, X) where Y and X are the polar stereographic grid. The file that I ...
4
votes
1answer
95 views

Converting NOAA's World Ocean Database NetCDF files to tabular data using Python

I'm trying to convert variables from NetCDF files to tabular data, but can't understand how to group observations by some index or key variable. For example, when loading data from WOD queries using ...
2
votes
3answers
233 views

Mask xarray dataset using a shapefile [closed]

I have an xarray dataset of some satellite data and I'd like to mask it using a shapefile. I have previously been doing this using a combination of PIL, numpy and gdal but it would be cleaner to do ...
2
votes
1answer
469 views

Using xarray to resample and merge two datasets

I have one dataset of satellite based solar induced fluorescence (SIF) and one of modeled precipitation. I want to compare precipitation to SIF on a per pixel basis in my study area. My two datasets ...
2
votes
1answer
299 views

Using Rioxarray / QGIS Projection

For the past couple weeks I have been trying to view GOES17 data from netCDF files (converted to geotif) in QGIS 3.10 but cannot get the projection to work correctly. I have attempted numerous ...
2
votes
1answer
167 views

Indexing coordinates in order to get a value by coordinates from xarray

Firstly, I am a super rookie and just recently started working with GIS. Therefore I am not sure how to ask/word the question, or even if it makes sense. So bear with me. I have some NetCDF files, ...
2
votes
0answers
22 views

Extract time series for features from large masked xarrays

I have done this before with GDAL and Python, but was hoping to be able to use xarray to scale things up. Let's say I have three datasets: 1. A large multiband geotiff where each band is a different ...
2
votes
0answers
50 views

How to slice a reduced gaussian gridded grib with xarray?

I want: to get list of coordinates of points within the specified area (ideal would be geopandas from shapefile or something like this) I don't want to interpolate the grib, just extract points by ...
1
vote
2answers
346 views

Opening EOS netCDF4/HDF5 file with correct format using xarray?

I am using xarray (version 0.12.2) to work with the MODIS/Terra+Aqua MAIAC Land Aerosol Optical Depth dataset (MCD19A2.006). xarray successfully opens that dataset with the correct variables and ...
1
vote
2answers
195 views

How to clip an xarray to a smaller extent given the lat/lon coordinates?

I have a netcdf file showing elevation over Europe derived from GTopo30. Turns out that the extent of this raster file is too big to combine it with other layers, so I would like to crop it to a given ...
1
vote
1answer
52 views

NetCDF hourly data to year raster layers (using Python)

Having a NetCDF with a 'time', 'lat' and 'lon' dimension, where time is hourly during a year and the variable to extract is temperature, how do I calculate mean temperature throughout the year using ...
1
vote
2answers
48 views

How can I merge two bands with different sizes using Rioxarray?

I have two images that I want to combine as follows Expected result: I tried to use the function rioxarray.merge.merge_arrays() in the following way but I got this error that I can't understand: >&...
1
vote
1answer
51 views

NetCDF: Why store coordinates as matrix

I am reading the documentation of Python library xarray After having opened multiple NetCDFs and explored their contents, I see that some files store their coordinates as a matrix and some store ...
1
vote
0answers
26 views

Cannot visualize xarray dataframe after converting to NetCDF

I am trying to convert sample.csv dataframe - link no NetCDF here is what I did import xarray as xr import pandas as pd dfcsv=pd.read_csv('sample.csv') dfcsv=dfcsv.set_index(['latitude','longitude','...
1
vote
0answers
112 views

Calculating the area of each cell of a Dataarray (or Raster) using Python? [closed]

I would like to compute the area of each respective cell of a raster. The pixels are in degree coordinates, so it is not trivial to calculate the area of each one "manually". In R I know there is a ...
0
votes
1answer
80 views

Clip global data by polygon using rioxarray fails (off by 180 longitude)

I want to extract CMIP6 climate data within polygons defined by a selection of the Large Marine Ecosystems of the world. The data(CMIP6) are found in ranges from 0 to 360 degrees longitude, while my ...
0
votes
1answer
69 views

Accessing Numpy Array found within an XArray from Satpy

dask.array<shape=(76, 76), dtype=float32, chunksize=(76, 76)> Coordinates: crs object +proj=utm +datum=WGS84 +ellps=WGS84 +no_defs +units=m +zone=33.0 +type=crs * y (y) float64 ...
0
votes
2answers
316 views

Extract latitude and longitude from rotated coordinate system

I'm new to working with geographic data so please bear with me. I have the following data: bnds,projection_x_coordinate,projection_y_coordinate,realization,fog_area_fraction,...
-1
votes
1answer
2k views

How to change Numpy array shape [closed]

I have an array (Numpy of shape (100, 256, 256). How can I change this to (100, 256, 256,3)? I tried doing reshape but it doesn't work, Can anyone help me.
-1
votes
1answer
180 views

cartopy and xarray issues

I'm beginning to use netCDF4 data and therefore I have downloaded xarray and also cartopy (with pip). I have downloaded data from the climate data store and want to plot these data. I have a notebook ...