Re: reproject from a tiff to another tiff gives "destination band 1 appears to be read only"
toggle quoted messageShow quoted text
It's a good thing that you opened the destination (population) file in "r" mode. Otherwise, it could have been overwritten.
You must create an output array for the reprojected data and pass it as the second argument, along with dst_crs and dst_transform keyword arguments.
with rasterio.open("population") as population, rasterio.open("lights") as lights:
reprojected = numpy.zeros(population.shape, dtype=lights.dtypes)
reprojected, transform = rasterio.warp.reproject(rasterio.band(lights, 1), reprojected, dst_crs=population.crs, dst_transform=population.transform)
The reprojected array will be aligned with and have the same shape as lights.read(1).
On Mon, Nov 11, 2019 at 6:28 AM <simonm3@...> wrote:
Please can someone explain how I align a tiff file of lights with another of population to create two numpy arrays the same size and aligned. I tried: