Skip to main content

Questions tagged [rioxarray]

geospatial xarray extension powered by rasterio. https://github.com/corteva/rioxarray

51 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4 votes
1 answer
915 views

How to set band names of multi-band GeoTIFF asset upon upload to Google Earth Engine

I have created a multi-bands GeoTIFF using xarray in Python following this answer. When I display this raster or open it in QGIS, all the bands are named following the variable they represent: ...
e5k's user avatar
  • 160
3 votes
2 answers
1k views

How to delete a raster file after opening the raster in rioxarray

I wanted to able to delete a temporary file, after opening it with rioxarray and start to process the final product. I followed two ideas: a) with rioxarray.open_rasterio(temp_file) as raster: # do ...
Sebastian H's user avatar
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
2 votes
0 answers
471 views

How do I separate results from a multi-geometry rioxarray clip opeartion?

I have MODIS data .hdf format and multiple polygons representing regions of interest. I can clip the raster using rioxarray such that polygons = [polygon1, polygon2, polygon3, ... ] with rioxarray....
wirrell's user avatar
  • 21
2 votes
1 answer
520 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
  • 511
2 votes
0 answers
1k 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 ...
Blizzard's user avatar
  • 197
1 vote
1 answer
110 views

User-defined reprojection using rioxarray

I'm trying to reproject a raster dataset using a user-defined projection in Python. I was able to achieve the desired reprojection setting ArcGIS's arcpy.CreateCustomGeoTransformation_management tool ...
Liyuneh's user avatar
  • 11
1 vote
0 answers
29 views

Merge Arrays (Mosaic) larger than RAM

I have a bunch of GeoTIFF files. These are about 100 GB on drive, when using compression with zstd (speed level). Hence, when loading, they are still much larger. I can load them in rioxarray with ...
tetje's user avatar
  • 99
1 vote
1 answer
61 views

Reproject large raster using Python

I have some large rasters that I want to reproject in a memory-safe way, using a second raster as a template . This code works nicely for smaller ones, but when they are large the Python kernel ...
TheRealJimShady's user avatar
1 vote
0 answers
101 views

IndexVariable objects must be 1-dimensional Error when reprojecting data

I seem to be having problems with retrojecting data. from xarray import open_dataset import xarray import rioxarray url = "..." crs = "..." dataset = open_dataset(url, ...
Marcel's user avatar
  • 111
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
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 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
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
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
1 vote
1 answer
1k views

How to fix CHECK_DISK_FREE_SPACE problem while writing a file with rioxarray?

I get this warning when I try to write out a raster using rioxarray: Free disk space available is 0 bytes, whereas 1152072000 are at least necessary. You can disable this check by defining the ...
hmnoidk's user avatar
  • 709
1 vote
1 answer
776 views

Extract by polygon from a rioxarray's raster

I'm attempting to extract NBR mean value from MODIS data based on a set of polygons. The polygon set has overlapping everywhere (don't blame me, it's not my work nor my idea). The shapefile is ...
aldo_tapia's user avatar
  • 13.7k
1 vote
0 answers
31 views

Polygon clipping with percentage tile membership

Let me setup the problem: I have a tiled world map (0.1° x 0.1°) with values assigned to each tile. I want to assign the values to each country, and I'm doing so by clipping to their ZEE mask. But ...
marcopolobronch's user avatar
1 vote
0 answers
640 views

rioxarray - masks as no data

So far, I always used nodata with the method rio.write_nodata(). But new raster I had several bands and I only want that pixel to be nodata, when every channel of the pixel is a no data value. How ...
Sebastian H's user avatar
1 vote
1 answer
1k views

Multiprocessing clipping Python rasterio/rioxarray

Clipping a raster often takes a larger percentage of my computation time, therefore I want to try it in parallel. I tried multiprocessing with Python's multiprocessing or pathos. But I often either ...
Sebastian H's user avatar
1 vote
0 answers
233 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
1 vote
1 answer
2k views

ImportError: cannot import name 'CRS' from 'pyproj'

I am getting the following error message when I am importing the rioxarray library. In my conda env I have installed the pyproj version 3.1.0 Has anyone came across the same issue? How can I fix it? ...
Dimitris Kasabalis's user avatar
1 vote
2 answers
193 views

Python array based alternative to GRASS r.cost

I am looking for a numpy array based alternative to the GRASS r.cost function. I have a friction surface raster where the value of each cell corresponds to travel time. I would like to find the cells ...
aps_fm's user avatar
  • 11
1 vote
1 answer
727 views

Why do I have such a high memory usage for this rioxarray code?

For my code using rioxarray I am opening quite an amount of raster files. One after another. I even added del to remove those from memory, even though I thought it would not be necessary, because they ...
tetje's user avatar
  • 99
1 vote
1 answer
825 views

rioxarray and vector data (including geocube)

I currently got some problem with rioxarray and geocube. I hope, this is the right place to ask. I am using a vector file for the German state of Brandenburg, so it has a massive hole in it. The file ...
tetje's user avatar
  • 99
0 votes
0 answers
20 views

Merging arrays creates gaps betwen, the rasters

I merge many hundred rasters all in the same projection, same orientation, same resolution. The next raster should start where there last ended (no overly, zero gap). I merge DataArrays with rioxarray'...
tetje's user avatar
  • 99
0 votes
0 answers
9 views

Clipping DataSet leaves pixel outside of desired Polygon

I'm trying to use the clipping from rioxarray to focus on a ROI defined by a bounding box, using the following code : from shapely.geometry import box ds = ... # Clip the Dataset geodf = geopandas....
Bastien Kovac's user avatar
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
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
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
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
0 votes
1 answer
127 views

How does rioxarray reproject match handle nan values?

I have a couple GeoTiffs where the "no data" value is set to 32767. I want to set those values to NaN and then use nearest neighbor interpolation to resample the data and match the ...
MKF's user avatar
  • 571
0 votes
0 answers
329 views

Access to the coordinates of a NetCDF file

I started working with NetCDF files recently. I'm working with projected Surge Levels; Data is stored as filename.nc files at Copernicus. This is the file. I got it using an API from their website. ...
terauser's user avatar
0 votes
0 answers
52 views

Reproject by Estimate_utm_crs()

If I am using function x.rio.reproject(x.rio.estimate_utm_crs()) then am I actually considering also parallels? The width and height of pixel changes with different longitude for me, however, The UTM ...
Luckasino's user avatar
  • 293
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
519 views

Using xarray to write NetCDF4 to GeoTIFF, get AttributeError: 'DataArray' object has no attribute '_data'

I tried to convert GPM nc4 files from NASA into GeoTIFF, but I got an error. Here's my code: import xarray import rioxarray import os os.chdir(dir_path) xds = xarray.open_dataset( "3B-MO.MS....
Wesley Liu'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
0 votes
1 answer
405 views

Rasterizing shapefiles using Geocube

I am trying to create a raster from a shapefile, with cells assigned a value from a specific column within the shapefile. I am using geocube below but am getting an error saying AttributeError: '...
penguin's user avatar
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
0 votes
0 answers
812 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
0 votes
0 answers
444 views

Xarray to NetCDF with transform applied

I have a process that uses rioxarray to crop GeoTIFFs and create a nice xarray dataset. This works well. When I export to new GeoTIFFs they are perfect, coordinates and data are fine. When I try to ...
Jamie Dunbar's user avatar
0 votes
0 answers
90 views

Sentinel2 pixel values and grayscales in QGIS

My goal is to get the Sentinel-2 pixel values and coordinates. So I used python rioxarray_open.rasterio to load the Sentinel2 pixels values and plot the results in QGIS. pixel_value = rioxarray....
yongyuuu's user avatar
0 votes
0 answers
111 views

using rioxarrays plot in pycharm

Using the method print in pycharms jupyter notebooks will raised TypeError: can only concatenate tuple (not "str") to tuple, but when calling a cell afterwards the result will be ploted ...
Sebastian H's user avatar
0 votes
0 answers
416 views

Changing raster pixel values outside of polygon box using rioxarray

How do I change all raster pixel values outside of a polygon (keep the original values inside polygon) into a certain value? I have passed through rioxarray clip() like below from this link: ...
Happier's user avatar
  • 67
0 votes
0 answers
779 views

Shapefile to raster using Rioxarray

I want to convert a shapefile to a raster. Normally when using rasterio, I would be able to open the raster, copy the metadata, and then write the shapefile to a raster. That would look like this: rst ...
CrossLord's user avatar
  • 215
0 votes
0 answers
63 views

Transforms from the same file are different

Reading a NetCDF file in two ways: src = rasterio.open(f'NetCDF:{url}:Rad', 'r') and doing src.transform gives: Affine(2004.017315487541, 0.0, -5434894.700982174, 0.0, -2004.017315487541, 5434894....
Coddy's user avatar
  • 103
0 votes
0 answers
524 views

Different elevation values between using rasterio, xarray, rioxarray, gdal and QGIS

I am trying to extract elevation values from a DEM raster under array format by using some packages (rasterio, xarray, rioxarray, and gdal). However, they seemed to give me a different results from ...
Happier's user avatar
  • 67
0 votes
1 answer
541 views

Masking a NetCDF file 2D lat/lon with a shapefile in Python

I am trying to mask a NetCDF file with an shapefile. Here is my shapefile: Africa_Shape = geopandas.read_file('/content/gdrive/MyDrive/HighresMIP/control_1950/iho/iho.shp', crs="epsg:4326") ...
user191007's user avatar
0 votes
1 answer
782 views

How to extract exact values from a raster file (TIFF) using a shapefile, using xarray to open the raster

I have found a link online that extracts the values min mean max and median, this is using the zonal stats function. sjer_tree_heights = rs.zonal_stats(plot_buffer_path, ...
JH2021's user avatar
  • 1
0 votes
0 answers
777 views

NetCDF4 file to raster with Python

I am trying to read NetCDF4 files from data developed by Toshicika Iizumi (https://doi.pangaea.de/10.1594/PANGAEA.909132) on global crop yields. I would like to turn the data into a form that is ...
Atreya Dey's user avatar