Clean and fast and geospatial raster I/O for Python programmers who use Numpy
Questions tagged [rasterio]
244 questions
9
votes
2 answers
Encountered a error while pip install rasterio
I am working on windows 10 and encountered an error while executing pip install rasterio in anaconda prompt.
(base) C:\Users\skywalker>pip install rasterio
Collecting rasterio
Using cached…
![](../../users/profiles/11628461.webp)
Skywalker
- 99
- 3
9
votes
1 answer
Iteratively load image block by block where blocks are partially overlapped
Trying to process a large satellite image (~10GB). For memory efficient processing chunk of image (block/tile) is being loaded into memory in each iteration.
The sample code for this as below:
def process_image(src_img, dst_img, band_id=1):
…
![](../../users/profiles/6422069.webp)
tachyon
- 361
- 1
- 9
9
votes
1 answer
How do I use rasterio/python to mask a raster using a shapefile, to set the raster pixels inside the polygons to zero?
I am trying to create a land mask to apply to satellite imagery, that will set the pixels in a raster intersecting with a land mass to 0.
After experimenting with gdal, skimage, pyplot etc. I've found the method given in the rasterio cookbook to be…
![](../../users/profiles/7373858.webp)
Cate
- 351
- 5
- 16
6
votes
1 answer
Saving array as Geotiff using rasterio
I have the following numpy array:
supervised.shape
(1270, 1847)
I am trying to use the following code to save it to GeoTIFF using rasterio:
with rasterio.open('/my/path/ReferenceRaster.tif') as src:
ras_meta = src.profile
with…
![](../../users/profiles/8541953.webp)
GCGM
- 683
- 9
- 31
6
votes
2 answers
python mask netcdf data using shapefile
I am using the following packages:
import pandas as pd
import numpy as np
import xarray as xr
import geopandas as gpd
I have the following objects storing data:
print(precip_da)
Out[]:
![](../../users/profiles/9940782.webp)
Tommy Lees
- 843
- 7
- 20
6
votes
1 answer
Convert raster time series of multiple GeoTIFF images to NetCDF
I have a raster time series stored in multiple GeoTIFF files (*.tif) that I'd like to convert to a single NetCDF file. The data is uint16.
I could probably use gdal_translate to convert each image to netcdf using:
gdal_translate -of netcdf -co…
![](../../users/profiles/2005869.webp)
Rich Signell
- 12,639
- 3
- 40
- 67
5
votes
1 answer
How to change the dtype of a Raster using Rasterio
I've been having trouble dealing with no data values in Python's rasterio package when applying a polygon mask on a raster data set. This particular raster is Landsat uint8 with 7 bands and the no data value is not inherently specified because 255…
![](../../users/profiles/7232206.webp)
Mike B
- 51
- 2
5
votes
1 answer
Something wrong with how I'm bundling rasterio into an executable
Expected behavior and actual behavior.
I expected to compile a script using rasterio into an executable using pyinstaller. The script runs fine from within my python environment. However I am not able to freeze it into an executable using…
![](../../users/profiles/3783002.webp)
user32882
- 3,135
- 2
- 20
- 47
5
votes
1 answer
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:
…
![](../../users/profiles/5317274.webp)
EBo
- 295
- 1
- 2
- 16
5
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…
![](../../users/profiles/8877753.webp)
Mars
- 321
- 3
- 10
4
votes
0 answers
Reprojecting .tiff file with rasterio: CRSError: The WKT could not be parsed. OGR Error code 6
I am trying to re-projected a .tiff file to EPSG:32638 with the following code.
Versions I have installed:
Rasterio version 1.1.5
Numpy version 1.18.1
This is the code I am…
![](../../users/profiles/9736794.webp)
ecd
- 65
- 3
4
votes
1 answer
rio.plot.show with colorbar?
How can I add a colorbar after using rio.plot.show?
I've tried a bunch of things but have gotten various errors
Here's one way I tried:
fig, ax = plt.subplots(figsize = (16, 16))
retted = rio.plot.show(ds, ax=ax, cmap='Greys_r') …
![](../../users/profiles/1807163.webp)
rasen58
- 3,488
- 6
- 31
- 57
4
votes
1 answer
How to change the crs of a raster with rasterio?
I am trying to change the CRS of a raster tif file. When I assign new CRS using the following code:
with rio.open(solar_path, mode='r+') as raster:
raster.crs = rio.crs.CRS({'init': 'epsg:27700'})
show((raster, 1))
print(raster.crs)
The…
![](../../users/profiles/12879022.webp)
four_loops
- 117
- 8
4
votes
2 answers
How to georeference an unreferenced aerial image using ground control points in python
I have a series of unreferenced aerial images that I would like to georeference using python. The images are identical spatially (they are actually frames extracted from a video), and I obtained ground control points for them by manually…
![](../../users/profiles/8836524.webp)
Kat
- 121
- 2
- 9
4
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…
![](../../users/profiles/9201276.webp)
KenC
- 43
- 4