Skip to main content

All Questions

Tagged with
0 votes
1 answer
34 views

Invert latitude of NetCDF in Python / xarray

I thought it would be straight up, but I don't find a question like this one here. I created a NetCDF out of a GeoTIFF, but it did not have coordinates or CRS. I added it doing this: coords = { 'time' ...
ImanolUr's user avatar
  • 1,100
-1 votes
1 answer
58 views

Extending raster after rasterizing geodataframe using geocube

I have created rasterized a geodataframe using geocube make_geocube. The resulting xr.Dataset now has the extent of the underlying geodataframe vector data. Say, the bounding box would be covering ...
ChipChap's user avatar
0 votes
1 answer
249 views

When i save my xarray DataAarray the coordinates are wrong

I have three 3x3 arrays that are downsampled data from NOAA's Global Hydro Estimator (smaller to make it quicker for testing). One array is lats, one is lons, and one is rainfall. Here's a sample lons:...
JWB's user avatar
  • 604
2 votes
0 answers
552 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
0 votes
0 answers
52 views

Python, colorize raster randomly avoiding same color for adjacent cells

I'm processing GeoTIFF rasters with python and xarray. The file contains some cells with different values. It looks like that: There are about 100 different values in the file and each value needs to ...
riuss's user avatar
  • 15
2 votes
1 answer
249 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
300 views

Pixel-based regression using xarray has incorrect P-value, but everything else is correct

I am using the code from this website to perform a regression on each pixel of an image time-series of rain and NDVI. The code works for everything, that is the outputs match the outputs of scipy, for ...
SoupBones's user avatar
0 votes
0 answers
860 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
1 vote
1 answer
2k views

xarray NetCDF with groups to GeoTIFF

I am trying to convert NetCDF files, available from this link, to raster or geotiff files using Python 3. After reading the a NetCDF file using the package netcdf4, it appears to have groups: CO2, ...
Atreya Dey's user avatar
0 votes
1 answer
807 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
1 answer
2k 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 ...
marcgm's user avatar
  • 95
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
1 vote
2 answers
1k 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: >&...
Ruben Silva's user avatar
1 vote
0 answers
675 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 ...
FAD's user avatar
  • 11