Clean and fast and geospatial raster I/O for Python programmers who use Numpy
Questions tagged [rasterio]
440 questions
0
votes
1 answer
import rasterio in AWS Lambda
When I'm trying to import rasterio in AWS Lambda I receive the following error:
Unable to import module 'lambda_function': No module named 'rasterio._base'
At first, I received the following error:
Unable to import module 'lambda_function': No…
0
votes
0 answers
How to write tiff file using rasterio?
In the code below, I am trying to write a dataset. The GTiff file has data and the image is clear but when I run the below code, the result of
dataset.write(total.astype(rasterio.uint16), 1)
is a black image.
Please let me know how to read part of…

Amrmsmb
- 1
- 27
- 104
- 226
0
votes
0 answers
Convert a singleband Tif image to a pseudocolor singleband image using Python
I have read through a lot of posts concerning this topic but I just could not find a solution for my problem. I have a raster image where I extracted the array with the values of the one band and normalized it to meet the range (0,255). However,…

veka
- 37
- 6
0
votes
1 answer
Rasterio.merge removing images
I am experimenting with merging landsat 8 bands. My dataset has several B3 bands close together
import rasterio
from rasterio.plot import show
from rasterio.merge import merge
from rasterio.warp import reproject
import os
from matplotlib import…

isaacm
- 23
- 1
- 4
0
votes
1 answer
Combining rasters with a slightly different size
I have two rasters that I clipped using the same shapefile. I then used gdal to resample them into the same resolution but now I have an issue where the shapes are very similar but not quite the same. How do you suggest fixing this? I've been stuck…

Phanster
- 65
- 6
0
votes
1 answer
testing crs between geodataframe and rasterio object
I check crs congruency as means of quality control prior to spatial analysis involving a geodataframe (gdf) and a raster (rstr).
print(gdf.crs)
returns 'epsg:2193'
and
print(rstr.crs)
returns 'EPSG:2193'
which is notionally OK as cross-checking in…

CreekGeek
- 1,809
- 2
- 14
- 24
0
votes
1 answer
Is there some clashes between rasterio and shapely?
I try to use natcap.invest module which needs shapely module, and also use rasterio module in my project. It can work successfully if I just import natcap.invest module. But it seems cannot work if I import natcap.invest and rasterio at the same…

BluePegas
- 11
- 1
0
votes
1 answer
Using rasterio (python) in Visual Studio Code - "does not exist in the file system, and is not recognized as a supported dataset name."
I am trying to use rasterio in Visual Studio Code for Windows. I downloaded the rasterio and GDAL binaries from: https://www.lfd.uci.edu/~gohlke/pythonlibs/ and installed them using "py -m pip install ". Visual Studio Code says the packages are…
0
votes
1 answer
error "too many values to unpack" while converting generator object to list
I'm using rasterio sample module and I want to convert my output (generator) to list. I know that I can just use list() but it raises error "too many values to unpack (expected 2)". When I just use the sample module I get generator:
sample =…

Edyficjum
- 81
- 6
0
votes
0 answers
Inserting 'with' statement within 'for' loop python
I'm trying to use Rasterio to crop all of the images within a folder. I can crop 1 image individually, but I can't embed/nest my 'with' statement after my 'for' statement so that I can run through a list of file paths - I'd really appreciate any…

GenieV
- 33
- 5
0
votes
2 answers
Resampling a raster using rasterio - simple modification of grid spacing
I am resampling raster data using Python's rasterio. Looking at the rasterio.enums.Resampling class, it appears the only way to do this is to interpolate between adjacent raster grids, essentially smoothing the data.
Is there some way to do a simple…

Kingle
- 496
- 1
- 6
- 20
0
votes
1 answer
Rasterio MemoryFile to Pillow image (Or base64 output)
I'm trying to write an AWS Lambda function that takes a TIFF, converts it to JPEG, then outputs it in base64 so that lambda can serve it. But I keep running into malformed response, or issues with reshape_as_image saying axes doesn't match array.
My…

Kevin Redman
- 459
- 4
- 15
0
votes
0 answers
Stop rasterio from resampling raster data
I am trying to plot a raster with rasterio but somehow that data is being resampled, I think.
The map created does not show the detail in the data. See here:
python plot
...compared to the original data (plotted with GIS):
topo data
Any idea how to…

Ashley Broadbent
- 1
- 1
0
votes
1 answer
How to assign particular color to each pixel in image
I have a single band raster tif image with 5 values i.e 4,3, 2, 1, 0 .
This code displays image with random color assigned to each pixel value
import rasterio
from rasterio.plot import show
import matplotlib.pyplot as plt
img_data =…

bdur
- 341
- 1
- 8
- 17
0
votes
1 answer
only size-1 arrays can be converted to Python scalars / Rasterio
I have this code and my aim to calculate the sin of my raster in the power of 0.8.
import os
os.chdir('D:/NOA/Soil_Erosion/test_Project/Workspace/Input_Data_LS_Factor')
import rasterio
import math
data =…

Melpomeni_Zoka
- 1
- 1