New answers tagged

0

Check your array dimensions using rf.shape. Try to skip axis parameter: import numpy as np a = np.array([[1,2], [3,4], [5,6]]) print(a, '\n') b = np.rot90(a) print(b, '\n') c = np.rot90(a, axes=(0, 1)) print(c) error = np.rot90(a, k=1, axes=(1, 2)) Traceback (most recent call last): File "/tmp/sessions/635a4f4228bcccc0/main.py", line 8, in &...


2

Reprojecting is not the way. You need to create a rasterio dataset. You can create an in-memory dataset using a rasterio.MemoryFile using the georeferencing from your original dataset. Assuming you have not clipped or resampled your numpy array, here is a method to generate an in-memory dataset: from contextlib import contextmanager import rasterio # use ...


0

This Page seems to have the answer you are looking for. You need to use rasterio.warp.calculate_default_transform() Create your raster in EPSG:4326 as you have already done reproject according to the method in the link (just tested it - it works) from rasterio.warp import calculate_default_transform, reproject, Resampling filename = 'my_4326_file.tif' ...


0

Thank you Algobotics for posting this: https://www.youtube.com/watch?v=ueUgHvUT2Z0 It has solved the problem


0

Here's an approach for arbitrary reclassification of integer rasters that avoids using a million calls to np.where. Rasterio bits taken from @Aaron's answer: import rasterio import numpy as np # Build a "lookup array" where the index is the original value and the value # is the reclassified value. Setting all of the reclassified values is cheap ...


Top 50 recent answers are included