Questions tagged [rasterio]

Clean and fast and geospatial raster I/O for Python programmers who use Numpy

440 questions
13
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…
ecd
  • 165
  • 1
  • 7
12
votes
4 answers

Rasterio Source shape is inconsistent with given indexes 1

I need to save out a 3 band geotiff to file. I am currently using rasterio and when I go to write out the 3 band imagery I get the error Source shape (1, 3445, 4703, 4) is inconsistent with given indexes 1. My final goal is to be able to perform…
freegnome
  • 121
  • 1
  • 1
  • 5
12
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…
user11628461
11
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): …
tachyon
  • 471
  • 3
  • 14
11
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…
Cate
  • 431
  • 1
  • 7
  • 22
10
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…
Mike B
  • 101
  • 1
  • 3
9
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…
GCGM
  • 901
  • 1
  • 17
  • 38
8
votes
4 answers

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') …
rasen58
  • 4,672
  • 8
  • 39
  • 74
8
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…
four_loops
  • 235
  • 1
  • 2
  • 9
8
votes
1 answer

rasterio and gdal DLL load fail in PyCharm

I have a conda environment with rasterio installed and a whole load of other libraries, including gdal. When I do: import rasterio on jupyter notebook, it loads fine and I can utilise it's methods etc.. When I do exactly the same thing on PyCharm,…
arsenal88
  • 1,040
  • 2
  • 15
  • 32
8
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…
Rich Signell
  • 14,842
  • 4
  • 49
  • 77
7
votes
3 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…
Kat
  • 311
  • 1
  • 3
  • 11
7
votes
2 answers

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…
user32882
  • 5,094
  • 5
  • 43
  • 82
7
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[]:
Tommy Lees
  • 1,293
  • 3
  • 14
  • 34
6
votes
0 answers

Fail to load module Jupyter but not in Terminal

I am creating a conda env with the following commands in my Windows machine: conda create -n s1 python=3.6 conda activate s1 conda config --env --add channels conda-forge conda config --env --set channel_priority strict Then, I install the…
GCGM
  • 901
  • 1
  • 17
  • 38
1
2 3
29 30