-1

I have a dataset which has a high resolution of 30m (let's say classification Land-Use data) and another dataset with a lower resolution of 36km (let's say Evaporation data) for the same region. I want to remove some points from the lower resolution array-based on the high-resolution array. For example, I want to exclude the pixels in Evaporation data, which have a Land-use class '10' above a certain threshold/percentage.

Description (if needed): Let's consider the high-resolution (first image below) to an array of 10x10, and a lower resolution image to be an array of 2x2 (second image below).

enter image description here enter image description here

I want to remove points on lower resolution image based on values of higher resolution image. Consider them overlapping perfectly, let's say if a said threshold of zero's (let's say more than 50%) from the first image appear in the quadrant (based on second image quadrant) a NaN value would be assigned to the second image pixel.

I have done this kind of masking using ArcMaps, but I have no idea if this is possible using python.

norok2
  • 25,683
  • 4
  • 73
  • 99
Ep1c1aN
  • 683
  • 9
  • 25
  • Any reason why the second image is colors? – norok2 Oct 18 '19 at 18:08
  • Are the shapes of the hi-res image and the low-res image always divisible? – norok2 Oct 18 '19 at 18:15
  • I could have numvered them, but numbering the second dataset doesn't serve a purpose. And I think that the shapes are always divisible. – Ep1c1aN Oct 18 '19 at 18:42
  • 1
    So please provide an **additional**, marked up image showing what the expected answer is and why that's the answer. Thank you. – Mark Setchell Oct 18 '19 at 22:36
  • This is a very specific request that requires code and sample images. It might be best to create a workbook on an online platform that anyone can access. I would suggest Google Collab: https://colab.research.google.com – shanecandoit Oct 18 '19 at 17:49

1 Answers1

0

To use NumPy, you need to transform the low-res data onto the same grid as the high-res data, requiring them to be perfectly aligned. You could use scipy.ndimage.zoom for this (see example on the docs page).

Or, if they aren't perfectly aligned (or rotated, or whatever), then geopandas is perfect for this.

Matt Hall
  • 7,614
  • 1
  • 23
  • 36
  • I tried that actually, but with a different method to get the grids in the same size. It was basically the same thing. It turns out that when you downscale the data, pixels with least frequency get suppressed and the end result suffers a lot. – Ep1c1aN Oct 18 '19 at 20:02
  • @Ep1c1aN You should be upscaling, using NEAREST_NEIGHBOUR, not downscaling! – Mark Setchell Oct 18 '19 at 23:05
  • Oh sorry. I meant, I converted the high resolution image to low resolution using `cdo remapnn`, which is same as Nearest Neighbour interpolation. – Ep1c1aN Oct 19 '19 at 02:32