Skip to main content

Questions tagged [rioxarray]

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

Filter by
Sorted by
Tagged with
12 votes
4 answers
27k views

Converting NetCDF dataset array to GeoTiff using rasterio Python

I have read a NetCDF file using the netCDF4 library and then read one of its datasets ("Evapotranspiration") into a variable (variable contains array) using the following code. Subsequently ...
RRSC NGP's user avatar
  • 658
8 votes
1 answer
7k views

Adding projection to Satellite NetCDF file

I have been working with satellite data from the GOES-16 satellite for quite some time now. A sample .nc file for this data is located at this NOAA AWS link I use gdalwarp to transform it for Mapbox ...
David 's user avatar
  • 242
7 votes
1 answer
12k 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 ...
Ep1c1aN's user avatar
  • 179
6 votes
1 answer
17k views

Masking NetCDF time series data from shapefile using Python

I have a 3-D time-series precipitation data (187 x 1800 x 3600), stored in a NetCDF file. I need to obtain the precipitation data for a shapefile. import matplotlib.pyplot as plt from netCDF4 import ...
Ehsan's user avatar
  • 75
6 votes
2 answers
3k views

Vectorizing a raster containing holes using rasterio

I want to vectorize raster that contains holes (nodata) in the areas with valid data. My current version uses rasterio.features.shapes: shape_list = list(shapes(raster.values, mask=raster.values !=...
Sebastian H's user avatar
6 votes
1 answer
3k 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 ...
ba0a2794's user avatar
6 votes
1 answer
10k views

Using rioxarray to assign spatial reference (EPSG:4326) to NetCDF built from CSV with lat long columns

I am trying to create a NetCDF from a CSV file. The idea comes from the fact that the original CSV comes with many columns, three of these representing: a specific year ("time") the Y ...
umbe1987's user avatar
  • 3,785
5 votes
3 answers
8k views

Extracting data from a raster

I'm currently working on a project where I have to use the Corine Land Cover (CLC) map. https://land.copernicus.eu/pan-european/corine-land-cover/clc2018 (You can download the map in the .tif format) ...
ktop's user avatar
  • 55
5 votes
2 answers
1k views

Can I open remote datasets with Rasterio?

I know I can open remote datasets with GDAL, I was wondering if I can do the same with Rasterio? GDAL bindings code of what I mean by opening remote dataset: import gdal import numpy import matplotlib....
Ruben Silva's user avatar
5 votes
3 answers
345 views

Raster Statistics of Fire Driven Forest Loss within shapefile

I have two inputs, a) shapefile, which I am reading in as a geodataframe, download here: https://we.tl/t-QxfgtLWOVN b) raster data from - GFW Fire Driven Forest Loss dataset, download here: https://...
Stuey17's user avatar
  • 199
5 votes
1 answer
2k views

Raster conversion from NetCDF to GeoTIFF changes data values

I am trying to convert a NetCDF file to a GeoTIFF. I've followed the steps outlined in Converting NetCDF dataset array to GeoTiff using rasterio Python and everything works fine. However, when looking ...
ColinB's user avatar
  • 233
5 votes
2 answers
446 views

MissingCRS error while opening MODIS data using rioxarray

I have a MODIS data. It is a hdf file (not hdf5). I can open it using ArcGIS and QGIS with no crs. When I use the following script, I get MissingCRS: CRS not found. Please set the CRS with 'rio....
Kadir Şahbaz's user avatar
4 votes
2 answers
7k views

Convert raster to CSV with lat, lon, and value columns

I'm looking for a process to convert ASCII gridded data (in this case 60min/1 degree gridded ASCII population data (GPW) from SEDAC: https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-...
interwebjill's user avatar
4 votes
1 answer
4k views

How to save an xarray.DataArray directly as a Cloud Optimized GeoTIFF?

Is there a good way to produce a cloud-optimized GeoTIFF (https://www.cogeo.org) directly from an xarray.DataArray? At the moment it takes me a couple of steps to produce an intermediate regular ...
weiji14's user avatar
  • 1,751
4 votes
2 answers
2k views

Updating a subset of raster values using open source Python?

I have a source raster data set (tif file) and a number of polygon features. For each one of those polygons I need to: a) 'clip' the raster. b) change values of those clipped raster cells (with the ...
Pitrako Junior's user avatar
4 votes
1 answer
3k 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....
Muser's user avatar
  • 225
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
1 answer
3k views

Converting a NetCDF from 0 to 360 to -180 to 180 via xarray

I've got an ERA5 NetCDF that's in 0 to 360 and I'd like to convert it to -180 to 180 before saving it off as a raster. I've got the current workflow set up, but am unsure of how to switch the longs. ...
JWB's user avatar
  • 604
3 votes
1 answer
829 views

Issue in calculating NDVI using Rasterio Python

I am trying to calculate NDVI using two clipped raster images of Landsat 7 (NIR & Red Bands clipped using mask file) using the following code: import rasterio as rio import numpy as np import ...
RRSC NGP's user avatar
  • 658
3 votes
1 answer
580 views

Why can't xarray find this variable?

I am very new to rasterio (about 20 minutes at this point). I am only trying to open a GRIB2 file and write to a GeoTIFF. I have installed all needed dependencies for reading GRIB files as well as ...
David 's user avatar
  • 242
3 votes
1 answer
6k views

"ValueError: negative dimensions are not allowed" when using raster created from NetCDF

My code creates a geoTiff from a NetCDF and then I'm trying to compute zonal_stats() from a raster file I created from a NetCDF. I end up getting ValueError: negative dimensions are not allowed at the ...
sheß's user avatar
  • 289
3 votes
1 answer
1k views

Difference between `reproject_match` and `interp_like`

I'm pretty new to GIS and I'm trying to understand the difference between the interpolation done with rioxarray reproject_match and xarray interp_like. Assuming I have two rasters da1 and da2 with ...
Serg's user avatar
  • 55
3 votes
1 answer
2k views

How to add a band to xarray dataset using rioxarray

I have two datasets, both rasters, which I would like to combine into 1 raster. This should not be difficult, but I'm having a hard time.. Both have the same extent/resolution etc. One raster has 231 ...
CrossLord's user avatar
  • 215
3 votes
2 answers
6k views

python rioxarray.clip masking netcdf data with a polygon returns all nan

My question is similar to what others have already asked but the posted solutions haven't worked for me. The similar posts are masking a netcdf file using a shapefile of points with rioxarray and how ...
kgclimatescience'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
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
2 answers
6k views

How to find coordinates of pixels of a GeoTIFF image with Python

I have a GeoTIFF image that looks like the following f = rxr.open_rasterio('myFile.tif') f5 = f.sel(band=5) f5.plot.imshow() I would like to create a Pandas dataframe with the values of each pixel ...
emax's user avatar
  • 269
2 votes
2 answers
4k views

No data found in bounds using rioxarray to clip GeoTiff to shapefile

I get the following error when trying to clip a GeoTiff to a shapefile: "No data found in bounds." Steps to reproduce: import rioxarray as riox rain = riox.open_rasterio( "https://...
Serg's user avatar
  • 55
2 votes
3 answers
15k views

Masking NetCDF data using shapefile (xarray & geopandas) [duplicate]

I am using the following packages: import pandas as pd import numpy as np import xarray as xr import geopandas as gpd I have the following objects storing data: print(precip_da) Out[]: <...
Tommy Lees's user avatar
2 votes
2 answers
995 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
2 votes
1 answer
225 views

Using coordinates to access GeoTIFF dataset

I'm trying to read a tile from the Sentinel1 SAR data collection. I'm using rioxarray to open the .tiff data file. rioxarray.open_rasterio( path_to_data, overview_level=...
Sina's user avatar
  • 21
2 votes
1 answer
6k views

Problem in setting dimension using rioxarray set_spatial_dims()

I am having trouble setting dimensions in a xarray object. I have created a xarray object (data, lats, and lons are 2D ndarray) and set a coordinate system as follows, and it is working. da0 = xr....
raraki's user avatar
  • 91
2 votes
2 answers
4k 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 ...
gioarma's user avatar
  • 133
2 votes
1 answer
2k views

Issue while performing merge/mosaic of multiple TIFF files using Rioxarray Python

I am trying the following code to mosaic/merge 10 image files (.tif files) using the following code: import rioxarray from rioxarray import merge from rasterio.plot import show items = [r'D:\...
RRSC NGP's user avatar
  • 658
2 votes
1 answer
440 views

Convert LR/LOLA data to latitude and longitude

I have height map data from here LR LOLA DEM from the Moon which seems to be "simple spherical" and I want to convert them to latitude and longitude with this: (It's a bit pseudo code) from affine ...
Augunrik's user avatar
  • 123
2 votes
1 answer
342 views

Converting NetCDF to GeoTIFF

I'm having trouble using rioxarray for converting one time layer of the .nc file to a GeoTIFF. I get the following error: MissingSpatialDimensionError: y dimension not found. 'rio.set_spatial_dims()' ...
Carla S.'s user avatar
2 votes
1 answer
370 views

How to use Python packages (GeoPandas, rioxarray) inside GRASS Python scripts?

I want to combine the functionality of GRASS GIS with other Python packages such as GeoPandas and rioxarray. My OS is Windows. It is possible to import other standard packages such as numpy and Pandas....
pittyplaetsch's user avatar
2 votes
1 answer
795 views

Mask rotated/curvilinear grid (NetCDF) with rectilinear grid (geotiff)

I have two datasets: Climate: avg one month temperature NetCDF File (CF Convention 1.6) grid_mapping_name: rotated_latitude_longitude (with rlat and rlong coordinates defining the grid) curvilinear ...
ProgMau's user avatar
  • 33
2 votes
1 answer
1k views

What data structure to use for raster data when using rasterio?

I want to write a method in Python that reads a raster (GTiff) using rasterio and returns its contents. Then, some processing is done. Finally, I want to write the data to a new GeoTiff. As far as I ...
Jan Pisl's user avatar
  • 726
2 votes
2 answers
78 views

Modify cells in a raster, that intersect or are inside a polygon without modify the other cells

I have a raster of a DEM (Digital Elevation Model with values in meters above sea level) in .tiff format, and I need to subtract the value of 10 from the elevation values of cells located within a ...
El Memo de Mileto's user avatar
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
2 votes
1 answer
630 views

Clip using geodataframe and rioxarry.clip not clipping xarray dataset

I am trying to clip an xarray dataset using rioxarray.clip with geometry from a geodataframe. I am running the code on a cloud platform built on kubernetes clusters in a distributed manner using Dask. ...
geospatial_laws's user avatar
2 votes
1 answer
2k 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
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
1 answer
2k views

RAM usage when working with large files with rioxarray [closed]

I am currently working with a large file in rioxarray. The File I want to write has the dimension 47, 24464, 23363, using the datatype uint8. Results into RAM usage of minimum 25 GB. Which I never ...
Sebastian H's user avatar
2 votes
1 answer
157 views

Why are the coordinates in the ODC different from the input data?

Why are the coordinates in the ODC different from the input data? I prepared the following example for clarification and discussion. The used dataset is shown in the following two images: Simple plot ...
Eike's user avatar
  • 173
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
2k 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
  • 53