Hot answers tagged

7

Xarray is (intentionally) ignorant of coordinate systems, so it has no special handling for cyclic coordinates such as longitude. Because your longitude array has only increasing values, xarray interprets selections like slice(40, -80) in the same way that x[i:j] works if x is a NumPy array and i > j >= 0, and thus returns an empty selection. The ...


3

The problem turned out to be a bug in GDAL, which is now fixed: https://trac.osgeo.org/gdal/ticket/6870.


2

It's impossible to do this kind of reshape [(100, 256, 256) -> (100, 256, 256,3)]. It's only possible a compatible reshape. This is an example: >>>import numpy as np >>>list = range(100*256*256) >>>array = np.reshape(list, (100, 256, 256)) >>>array = np.reshape(list, (100, 256, 256, 3)) #your reshape: I got an error! ...


1

I think one of the most evident advantages is indexing. Consider the following example where you have data and both longitude and latitude stored in 2D arrays: data = np.random.randint(100, 1000, size=(4, 4)) data [[176, 479, 713, 973], [992, 259, 969, 355], [182, 139, 633, 938], [761, 911, 124, 855]] x = np.linspace(-76, -74.5, 4) y = np.linspace(-5.0,...


1

I believe what you are looking for is rioxarray. An example of what you want to do is at: https://corteva.github.io/rioxarray/html/examples/clip_geom.html import rioxarray geometries = [ { 'type': 'Polygon', 'coordinates': [[ [425499.18381405267, 4615331.540546387], [425499.18381405267, 4615478.540546387], ...


Only top voted, non community-wiki answers of a minimum length are eligible