Questions tagged [xarray]

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

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

Creating not lattice data to xarray-dataset [closed]

I would like to know how to create xarray-dataset that is not lattice data(not mesh data). For example, if I want to write a dataset of "river depth" and "precipitation" data that ...
0
votes
1answer
20 views

Georeferencing Sentinel-3 LST product

I have been stuck attempting to convert Sentinel-3 LST netCDF data to geotiffs for a while now as part of my master's thesis. Firstly, an introduction to the data. It is packaged as follow: The data ...
-1
votes
0answers
21 views

Plot NetCDF4 as timeseries [closed]

I have a data set as an image and I would like to plot variables as time series daily. Do you have any suggestions?
-1
votes
0answers
12 views

Convert to datetime in Python [closed]

I have a set of data which is Day: 31 Month: 12 Year: 54, beginning at 1/1/1970 Then, how to convert them into 01:01:1970, 02:01:1970, .... I am using Python and Xarray, do ypu have any suggestions?
1
vote
2answers
49 views

Showing lat long instead of numbered index on spatial data map

I am trying to project meteorological data from a netcdf4 file with its latitude and longitude information and I am not getting how to show lat-long information on the x and y-axis, in the image ...
0
votes
2answers
31 views

How to mask and scale raster using rasterio?

I have been trying to read a raster file in netcdf format which I will later on sample. I need to read using the DatasetReader as float. When I read: ds = rasterio.open(f'netcdf:{file}:AOT_L2_Mean', ...
0
votes
1answer
47 views

Polygon Drill on Open Data Cube

I face a crucial problem with ODC. I try to do a spatial join with a shapefile (polygon drill). I have followed the following steps: Read the shapefile and get the first polygon to test Ensure that ...
0
votes
0answers
32 views

Time encoding for xarray to netCDF

While looking at this webpage, it seems there is an inconsistency for the time units handling. Copying and pasting from the webpage: from cftime import date2num time_units = 'hours since {:%Y-%m-%d 00:...
0
votes
0answers
46 views

Conflicting sizes for dimension 'time' with rioxarray

I've been using rioxarray to convert netcdf files to geotiffs, and up till now, it's worked great. However, when I open a ERA5 reanalysis netcdf dataset, rioxarray appears to find that the data size ...
2
votes
2answers
189 views

Open and plot a large raster with Python xarray

I have an ASCII Esri file of the type: ncols 5201 nrows 4001 xllcorner -65 yllcorner -35 cellsize 0.025 NODATA_value -9999 -9999 -9999 -9999 255 256 -9999 -9999 ... -9999 -9999 -9999 -9999 -9999 -9999 ...
1
vote
0answers
100 views

Creating raster stack from xarray in Python

I am trying to create a raster stack from an xarray dataset which I obtained from multiple NetCDF files. import netCDF4 as nc import rasterio as rio import numpy as np import xarray as xr import os ...
1
vote
0answers
32 views

Cut NetCDF files by shapefile [duplicate]

I have a large dataset of global .nc files and I am trying to clip them to a smaller area. I have this area stored as a .shp file. I have tried using GDAL from QGIS but needs to do this by converting ...
0
votes
1answer
190 views

Plotting xarray over background map using cartopy

I am trying to plot an xarray DataArray over a background map using cartopy. When including the background map, the DataArray is not visible, although the map has an appropriate extent. I am adding ...
0
votes
0answers
38 views

Adding timestamp to NetCDF xarray dataset

I am new to working with NetCDF datasets and Xarray in Python. I have an xarray dataset made from 100 TIFF raster files: As you can see there are 100 data variables, that are essentially the ...
1
vote
1answer
116 views

How to visualize a NetCDF Dataset

Suppose I have a rather large NetCDF file that I open as a dataset using xarray. import xarray nc_in = r"....\D_P_WGS84_comp.nc" nc_ds = xarray.open_dataset(nc_in) It is composed of ...
1
vote
0answers
58 views

Loading Open Data Cube data to match a raster with geographic coordinates?

I would like to load a raster from a GeoTIFF file, and then load a time series of data from the Open Data Cube into the same CRS and resolution so I can use the raster as a mask. I can use the raster'...
1
vote
1answer
391 views

Adding compression to a NetCDF file using xarray

I have a raster that I am trying to compress and convert to a NetCDF format with compression level = 9 using the xarray package. I assume that the compression is added using the encoding parameter as ...
1
vote
1answer
186 views

CRS Error when clipping NetCDF using a shapefile

When trying to mask a NetCDF (a daily time series of 31 days) with the code below, I get the following error related to the part of writing the CRS to the rio NetCDF data: CRSError: The WKT could not ...
1
vote
0answers
57 views

overlaying xarray data with shapefile using

import xarray import xshape import matplotlib.pyplot as plt da.xshape.overlay(shapefile,colors=['b', 'orange', 'g', 'r', 'c', 'm', 'y', 'grey', 'Brown', 'ForestGreen'],levels =10) I tried to plot ...
1
vote
1answer
135 views

Unable to read GRIB datas with XArray

I used this code to read grib data import os import numpy as np import pandas as pd import xarray as xr path = "gfsanl_4_2019101000.g2" os.chdir(path) ds = xr.open_dataset('...
1
vote
2answers
217 views

Find closest point to shapefile coastline in Python

I have a xarray (674 lats & 488 Lons) and want to find the closest distance for each point to the coastline in meters. I found this solution: Finding closest point to shapefile coastline Python ...
0
votes
1answer
150 views

Output GeoTIFF file is wrongly rotated to 90 degrees/ -90 degrees using xarray and rioxarray with NotGeoreferencedWarning warning

I am using this file. I wrote this code. import rioxarray import xarray xds = xarray.open_dataset("LIS_HIST_201401010000.d01 copy.nc") floodFraction = xds.FloodedFrac_tavg.transpose('...
2
votes
1answer
450 views

How to save a clipped NetCDF data as a new NetCDF file in Python?

I have used xarray to clip my NetCDF file‌ (it can be downloaded here) by a shapefile (it can be downloaded from here). Here is the code: import xarray import rioxarray import geopandas from shapely....
1
vote
2answers
218 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: >&...
2
votes
0answers
38 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 ...
3
votes
3answers
2k views

Mask xarray dataset using a shapefile [closed]

I have used xarray on some satellite data that 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 this ...
0
votes
1answer
277 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 ...
4
votes
1answer
1k 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, ...
3
votes
2answers
2k 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 ...
3
votes
1answer
1k 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
0answers
99 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
0answers
30 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
1answer
137 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 ...
4
votes
1answer
171 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
1answer
1k 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 ...
0
votes
1answer
126 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 ...
1
vote
1answer
96 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 ...
4
votes
2answers
750 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 ...
6
votes
1answer
3k 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 ...
1
vote
2answers
562 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
199 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 ...
1
vote
0answers
163 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 ...
5
votes
1answer
793 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 ...
-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.
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 ...