Clean and fast and geospatial raster I/O for Python programmers who use Numpy
Questions tagged [rasterio]
440 questions
6
votes
1 answer
AttributeError: module 'rasterio' has no attribute 'mask'
I am trying to learn sentinelsat by following some tutorials. Part of the codes goes like this.
import rasterio as rio
import geopandas as gpd
nReserve = gpd.read_file('NReserve/NaturalReserve_Polygon.shp')
nReserve_proj = nReserve.to_crs({'init':…

mir abir hossain
- 101
- 1
- 6
6
votes
1 answer
Provide a path to gdal-config using a GDAL_CONFIG environment variable error while attempting to install mapbox-tileset
when running pip install mapbox-tilesets I get the following error on my windows 10 computer during the Collecting rasterio process specifically the requirement to build wheel where I get the error. Details below.
Collecting rasterio
Using cached…

Sandy H
- 61
- 2
6
votes
2 answers
How to write PNG in rasterio from a stacked RGB?
I have 3 variables namely R, G, B. I want to make a PNG image based on the three using rasterio. I tried using np.dstack to stack the 3 images and use the result to write it.
Using rasterio, I tried to write it this way:
rgb = np.dstack((Nr,Ng,Nb)) …

Nikko
- 1,410
- 1
- 22
- 49
6
votes
2 answers
generating GeoTIFF colormaps
I am generating 2D statistical maps and would like to also generate and save the image colormaps. The mean-size image has a data type of float32. The following example modified from online sources:
with rasterio.open(name,'w',**profile) as dst:
…

EBo
- 355
- 1
- 3
- 17
6
votes
1 answer
Merging multiple bands together through gdal...correctly
I'm using some Sentinel-2 satellite images in python. Now I have no issues using the newer ones (past 2016). But I need to use some from 2016. These are not preprocessed in the same way by the European Space Agency!
Normally when you download a…

Mars
- 341
- 1
- 3
- 12
6
votes
1 answer
python-xarray: how to convert individual-band raster data, for multiple bands and dates, to xarray-Dataset or DataArray?
I'd like to take raster (satellite imagery) data, and build a Dataset or DataArray, to speed up my image processing (I have to work on multi-band, multi-date satellite imagery a lot).
The data comes as individual bands for each image date, and I…

KenC
- 63
- 1
- 4
6
votes
3 answers
Rasterio installation failing
I am trying to update my rasterio version from 0.25 to 0.32 on a python 2.7 installation, but running up against foll. issue. Any info on how to fix it?
Running setup.py clean for rasterio
Failed to build rasterio
Installing collected packages:…

user308827
- 21,227
- 87
- 254
- 417
5
votes
1 answer
how to solve rasterio installation problem
When i install rasterio library i get this type of error mentioned below. How to overcome it? Can anyone help me with full procedure. Though i follow the installation instruction given in https://rasterio.readthedocs.io/en/stable/installation.html…

Azhlil Suraya
- 51
- 2
5
votes
1 answer
Set CRS for a file read with rasterio
I am reading a jpg image and its associated world file in Python with Rasterio like this:
import rasterio
with rasterio.open('/path/to/file.jpg') as src:
print(src.width, src.height)
print(src.crs)
print(src.indexes)
The image file and…

KarateKid
- 3,138
- 4
- 20
- 39
4
votes
0 answers
Getting Error while clip raster using shape file
# Read Shapefile
with fiona.open("/content/drive/My Drive/shapefile/shape_files/lidar_shape.shp", "r") as shapefile:
shapes = [feature["geometry"] for feature in shapefile]
# read imagery file
with rasterio.open("/content/drive/My…

PRAJAKTA
- 93
- 5
4
votes
0 answers
Use xarray to save DataArray as geoTiff, without using ram memory
I need to modify a very large geoTif file (over 200GB), however when I save it my code crashes as it loads the file in memory. The code looks like this.
import xarray as xr
# open the file
ds = xr.open_rasterio('file.tif')
# modify here
.....
#…

ferlix
- 61
- 1
- 5
4
votes
2 answers
How can a choropleth map be combined with a shaded raster in Python?
I want to plot characteristics of areas on a map, but with very uneven population density, the larger tiles misleadingly attract attention. Think of averages (of test scores, say) by ZIP codes.
High-resolution maps are available to separate…

László
- 3,914
- 8
- 34
- 49
4
votes
1 answer
Setting raster cells equal to zero to no data in Rasterio
Given a random raster tif file, I want to set all cells which have a value of 0, to 'no data' using Python/rasterio. I just cant seem to find documentation about this simple operation.
import rasterio
src =…

mcdesign
- 105
- 1
- 6
4
votes
1 answer
Open raster using rasterio and s3
I'm storing rasters in Amazon S3 bucket and would like to open specific object using installed rasterio library in my Django docker container.
AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY_ID are incluced in docker-compose.yml env variables.
Inside docker…

sorryMike
- 769
- 9
- 25
4
votes
1 answer
rasterio transform and affine
Im trying to do some basic image filtering. Ive included a snippet verbatim from the rasterio cookbook (I removed .astype() from the median filter output). The issue is that my input and output rasters should have the same extent but dont. The…

user2005667
- 43
- 1
- 3