1

I have two raster files, one at 30m resolution and one at 100m resolution. I would like to take the coordinates of each pixel of the 30m resolution raster and then extract the values at each of these coordinates from the 100m resolution raster. The end goal is a 30m resolution raster with values from the 100m raster.

I'm using Python and I've tried using the rasterio module but I'm struggling to understand how to extract the lat/lon (or row/col) points of each pixel.

My CRS is: WGS84, EPSG 4326

My resolution is: res: (0.0002694945900000002, 0.00026949459)

My code so far:

import numpy as np
import skimage.transform as st 
import rasterio
import pyproj

30m_file = rasterio.open(path_to_30m_file)
100m_file = rasterio.open(path_to_100m_file)

band1 = 30m_file.read(1)
print("band1:", band1)

#Access values based on georeferenced space
x, y = 30m_file.bounds.left + 0.003, 30m_file.bounds.top - 0.002
row, col = 30m_file.index(x, y)
print("row:", row)
print("col:", col)
print("example value:", band1[row, col])

#The logic would then follow:
# for every pixel lat/lon in 30m file
    # open 100m file
        # extract 100m value at those 30m pixel lat/lon
        # keeping 30m resolution

But accessing the coordinates and then parsing through them is what's stopping me.

  • You should have a look at [this post](https://stackoverflow.com/questions/27861197/how-to-i-get-the-coordinates-of-a-cell-in-a-geotif) – Val Mar 11 '20 at 16:06

0 Answers0