Questions tagged [rioxarray]
geospatial xarray extension powered by rasterio. https://github.com/corteva/rioxarray
98
questions
1
vote
1
answer
18
views
RuntimeWarning when I try to plot a raster
I'm using JupyterNotebook to analyze some GIS data. I need to clip a raster and plot the result but I've a strange problem. Folder with data is here; the raster size is 1MB.
I'm be able to plot the ...
1
vote
1
answer
25
views
How to convert crs_wkt starting with GEOGCRS to a ogc_wkt string (to use rioxarray.reproject_match)
I have two xarray data arrays (1. land_data, 2. climate_data) that I want to reproject and match (rio.reproject_match()):
climate_data_matched = climate_data.rio.reproject_match(land_data)
Land data ...
0
votes
1
answer
34
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....
0
votes
0
answers
11
views
Reading Sentinel-5P data throws "UnicodeDecodeError" using rioxarray Python
I am trying to read Sentinel-5p data using following code:
import rioxarray
netcdf_fname = r'D:\Projects\S5P_OFFL_L2__CH4____20220509T074431_20220509T092601_23678_02_020301_20220510T234447.nc'
rds = ...
1
vote
1
answer
23
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 ...
0
votes
0
answers
17
views
Mask non value flags when opening dataset with rioxarray
I'm trying to read Leaf Area Index (LAI) data from the MODIS product (MOD15A2) using rioxarray, but there are a number of land cover flags (e.g. 253 = land cover assigned as barren) that don't get ...
0
votes
1
answer
25
views
Add projection to rioxarray dataset in Python
I've downloaded a netcdf from the Climate Data Store and would like to write a CRS to it, so I can clip it for a shapefile. However, I get an error when assigning a CRS. Below my script and what is ...
0
votes
1
answer
31
views
How to stack list of Xarrays
I have a folder with 4 .tiff (GeoTiff) files. Each of these contains two layers (the spectral band and a mask). I'm able to create a list containig each image using xarray.open_rasterio.
Now I need to ...
0
votes
1
answer
65
views
Converting raster GeoTIFF or NetCDF to image in Google Earth Engine
I try to convert raster tif or netcdf file to ee.Image Google Earth Engine object in Python. The netcdf raster testing data (5-bands) is in this link. Here I converted the first band from raster file ...
1
vote
0
answers
15
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 ...
0
votes
0
answers
22
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 ...
0
votes
1
answer
21
views
Wrong results using xarray groupby to calculte anomalies
I want to compute ten days anomalies based on MODIS NDSI. The data is stored as a GeoTIFF. For this task I have two folders, one with the reference period of 2001-2020 and one with 2001-2022 for which ...
1
vote
1
answer
83
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 ...
2
votes
1
answer
90
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 ...
1
vote
0
answers
37
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 ...
0
votes
1
answer
64
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 ...
1
vote
0
answers
29
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 ...
0
votes
0
answers
42
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....
1
vote
2
answers
104
views
rio.write_crs() leaves empty crs
I have a dataset ds which looks like this:
<xarray.Dataset>
Dimensions: (time: 42, long: 1383, lat: 586)
Coordinates:
* time (time) datetime64[ns] 1979-01-01 1980-01-01 ... 2020-...
1
vote
1
answer
187
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 ...
1
vote
0
answers
45
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....
0
votes
1
answer
36
views
Transforming GPM Precip Data using rioxarray
I am working with GPM Precip data on a hydrologic study and I am having a hard time figuring out why the netcdf files I downloaded are giving me issues when I try and map the data.
I am still learning ...
0
votes
3
answers
115
views
Divide and write raster in GDAL using Python?
I have a folder of raster .tif. files. I want to iterate through all the rasters in this folder and divide them by a specific raster. I then want to take these outputs and write them to new rasters.
...
0
votes
0
answers
78
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....
3
votes
1
answer
117
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 ...
0
votes
0
answers
26
views
Creating Masks with osmnx and rasterio, could misalignments be due to projection?
I'm still quite new to geospatial data and I found that when I'm creating masks for my dataset (building and roads from open streetmap), they are slightly misaligned.
Now I see that this is also the ...
0
votes
1
answer
82
views
Sum of values in raster
Upon importing a raster file, how can I get the sum of all values given in the raster file?
import rioxarray as rxr
raster= rxr.open_rasterio(
'raster.tif',
masked=True
).squeeze()
...
1
vote
1
answer
379
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.
...
1
vote
1
answer
304
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 ...
0
votes
0
answers
58
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 ...
0
votes
0
answers
58
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:
...
3
votes
1
answer
1k
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 ...
0
votes
0
answers
41
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 ...
0
votes
0
answers
33
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....
4
votes
1
answer
344
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 ...
0
votes
0
answers
131
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 ...
0
votes
1
answer
378
views
Converting GeoTIFF file into NetCDF file in Python and file is empty [closed]
I am trying to convert a GeoTIFF file into NetCDF file (still remains all the information) using either rioxarray or xarray in python. The file is just empty. But when I checked the GeoTIFF file it ...
0
votes
1
answer
90
views
Rioxarray.merge.merge_datasets unable to merge xarray datasets [closed]
I am working with geospatial data and have been previously using rasterio's merge function to join adjacent tiles together. For memory reasons I have switched from using in-memory rasters to xarray ...
1
vote
1
answer
168
views
How to convert GeoTIFF file into NeCDF file in Python Jupyter notebook without changing any information?
I am looking for a way to convert GeoTIFF raster file into NetCDF file using Python Jupyter notebook. I have tried function gdal.translate and xarray (.to_netcdf) (as below), but both of them gave me ...
0
votes
1
answer
369
views
rioxarray: zero-size array to reduction operation minimum which has no identity
I'm trying to subtract one raster from another. They have a slightly different shape/extend but the same CRS/resolution. While attempting to subtract the raster, I received this error: 'zero-size ...
0
votes
1
answer
101
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")
...
1
vote
1
answer
143
views
Writing multiple python rasterio xarray results to file and naming each raster file
I am relatively new in using python for GIS, but I have the following code that I use to clip all created mosaics by a shapefile (aoi_shapefile). After the clipped rasters are placed in the rasterio ...
0
votes
0
answers
108
views
Converting NetCDF and grid file downloaded from ECMWF - ERA5 hourly single level archived data to GeoTIFF format
I haven't worked much on GIS data. I have downloaded files from ECMWF portal from dataset - ERA5 hourly data on single levels from 1979 to present. I want to convert this file to GeoTIFF format so ...
0
votes
1
answer
60
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,
...
0
votes
1
answer
707
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?
...
1
vote
1
answer
1k
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....
0
votes
1
answer
65
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 ...
-1
votes
1
answer
301
views
Resample (spatially-average) DataArray / raster to match the grid of another DataArray in Python [closed]
I would like to resample a DataArray / raster object to exactly match the spatial grid of another DataArray / raster object. In particular, the operation I want to perform is a spatial averaging to ...
1
vote
1
answer
192
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 ...
1
vote
1
answer
258
views
Data masking and plotting issues xarray/rioxarray | geojson -> geoviews
I'm loading a NetCDF file (ERA5 surface temperatures), then I mask the data using country shapes, and finally generate a plot using geoviews. For the unmasked data everything works as intended. As ...