Questions tagged [rasterio]

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

105 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
314 views

Stacking and masking Landsat at the same time with rasterio

Based on answers from previous questions 1,2 and the Masking a raster using a shapefile guide from rasterio cookbook, I wrote the code below. The code runs correctly. I would like to improve it. 1- ...
4
votes
0answers
604 views

Georeference an unreferenced image using rasterio in Python

I have unregistered/unreferenced 6 band TIFF images that I have been trying to export as georeferenced GeoTIFFs. The GPS coordinates of the corners of each image is known and each image is 1024 height ...
3
votes
0answers
29 views

Why do the rasterio Resampling methods ‘max’, ‘min’, ‘med’, ‘q1’, ‘q3’ give a segmentation fault?

I want to resample a georeferend raster .tif file with Python using rasterio. Here is the example I found example and the documentaion of the resampling methods. When I am using the following methods ...
3
votes
0answers
1k views

“RasterioIOError: This is a BigTIFF file. BigTIFF is not supported by this version of GDAL and libtiff” error message

I am trying to read a raster ".tif" file with rasterio: import rasterio raster_path = r'.........\file.tif' raster = rasterio.open(raster_path) but I am getting the following error message: "...
3
votes
0answers
331 views

Writing masked GeoTIFF in rasterio and visualizing in QGIS?

I have an interpolated raster, which is a masked array, that shows where the data is valid. I want to save it as masked TIFF with rasterio. To test, here's the JSON file, and the code: import ...
3
votes
0answers
201 views

Why can't I transpose a raster across the pole with rasterio or gdal, and how could it be done?

I have a raster in e.g epsg:4326, it covers all world, from 180E to 180W, from 90S to 90N. I want to re-project a part of it to epsg:3031 and also change the grid size and resolution. Here is a ...
3
votes
0answers
2k views

ImportError dll load failed the specified module could not be found (rasterio)

I want to use the rasterio package to make some test with the Planet Explorer Api (https://www.planet.com/docs/guides/quickstart-ndvi/). I've seen on many forums that I needed to use a wheel file to ...
2
votes
0answers
14 views

How to overlay and combine a choropleth and a shaded raster in Python?

I want to make a choropleth map of regions but shade it according to local population density. This is not the problem of masking a raster with a shapefile but to overlay two representations of data ...
2
votes
0answers
90 views

Problems installing rasterio from conda

I'm trying to install the rasterio python package using the conda package manager. But when I try to do this in a new clean conda environment, I get an "Found conflicts!" error with no information on ...
2
votes
0answers
21 views

Raster shapes are not exactly equal after cropping

I clipped multiple rasters to the shape of a polygon shapefile. But, the output rasters do not have exactly the same shapes. I am doing correlation analyses per pixel so I need the array shapes to ...
2
votes
0answers
46 views

Polygonize every single pixel of a raster

How can I get every pixel separated? When I calc unique values, if two pixels have the same value, it converts in one row in the final shape. I need every single pixel converted into one unique ...
2
votes
0answers
188 views

Plotting GoeDataFrame on a raster

I have a bunch of polygons which I loaded from a shapefile into a fields GeoDataFrame: geometry raster_val 0 POLYGON ((8.56799 47.80800, 8.56799 47.77200,...
2
votes
1answer
111 views

Using rasterio to show RGB image with nodata

This question is same as https://stackoverflow.com/questions/59132459/use-rasterio-show-rgb-image-with-nodata I have a multiband image with nodata value (which is Landsat and been set nodata to 0). ...
2
votes
0answers
221 views

Rasterize GeoJSON or Shapely Geometry?

I am trying to rasterize a GeoJSON or shapely geometry but it does not rasterize all the geometry (some of it is not in the TIFF-file). I tried gdal_rasterize -burn 255 -burn 0 -burn 0 -ts 4950 4900 ...
2
votes
0answers
317 views

How to fix rasterio error: The EPSG code is unknown. Unable to open EPSG support file gcs.csv

I try to open a jp2 image with the Python's Rasterio package. The code is below. The problem is that the coordinate reference system is not recognised and when I want to see the meta attribute of the ...
2
votes
0answers
187 views

Plotting Single Band & Multi-Band Stacked TIFF File using Rasterio in Python

I have 2 raster files (one single band and other multi-band stacked (465 bands) tiff file) which I am trying to plot using the following code: import rasterio as rio from rasterio.plot import show ##...
2
votes
0answers
37 views

Rasterio CLI warping multiple rasters like another raster in all minus one feature

I'm writing a bash script to warp all the rasters in a specific directory to match another raster. I'd like to warp all these rasters iteratively in to match the other raster in all was except shape ...
2
votes
0answers
2k views

Error installing Rasterio in PyCharm and in CMD Line

Error installing Rasterio in PyCharm (Settings > Project Interpreter) Collecting rasterio Using cached https://files.pythonhosted.org/packages/1a/d5/...
2
votes
2answers
2k views

rasterio mask method

I am using a simple ASCII raster file to test the rasterio.mask module ncols 4 nrows 4 xllcorner 0 yllcorner 0 cellsize 0.5 nodata_value -9999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 I generated the ...
2
votes
0answers
377 views

Rasterio is masking wrong area?

Okay, my goal is to mask a geotiff by means of a shapefile. Firstly, I made sure that the shapefile and geotiff had same projections: from osgeo import ogr, osr import gdal import os driver = ogr....
1
vote
0answers
9 views

Plot polygon outlines on raster with PolygonPatch (descartes) does not work

I'm trying to plot several polygons on a raster. Several posts suggest to use matplotlib and descartes like this one: Plot shapefile on top of raster using plot and imshow from matplotlib However, my ...
1
vote
1answer
19 views

Rasterio creating composite/stack much larger than the individual bands

I am using rasterio to create a stack of eight bands and each individual band is about 1GB, but when it's stacking them the output (with a lzw compression) is a tif that's over 53GB! This seems huge ...
1
vote
0answers
12 views

Rasterio mask removes alpha band

I have a geotiff image that I am clipping to a geojson polygon using rasterio. When I load input the image in QGIS, it has an alpha band (4 bands total). rasterio says it only has 3 bands, which ...
1
vote
0answers
17 views

How to write multitime NetCDF raster with rasterio and netCDF4?

My code is: import numpy as np import rasterio from rasterio.warp import calculate_default_transform, reproject, Resampling from netCDF4 import Dataset mask=rasterio.open(path1) dst_crs='EPSG:4326' ...
1
vote
0answers
35 views

Raster Zonal Statistics for large files

I have a shapefile that consists of 375m x 375m cells from the State of California, consisting of a total of 3,022,037 cells. The raster file covers the same geographical area, but consists of smaller ...
1
vote
2answers
38 views

Rasterio merging went wrong

I try to merge some multiband rasterfiles (Sentinel 2 data) with Rasterio into a single rasterfile but the result is incorrect. The files are too big to fit in my RAM completely, but I have enough ...
1
vote
0answers
70 views

Rasterio RGB band combo results in black TIFF

I am trying to to compose a RGB .TIFF image using rasterio with bands that I've downloaded from sentinel-2 (via sentinelsat). The resulting image is black. import rasterio # Open Bands 4, 3 and 2 ...
1
vote
0answers
27 views

Handling Nodata values in sklearn (working w pyimpute)

I'm using sklearn for a classification project. Because I'm relatively new to doing geospatial tasks outside of a GUI, I'm using Matt Perry's pyimpute (link has all the code for that module) to handle ...
1
vote
1answer
128 views

How to write BIGTIFF raster files with rasterio

A few months ago I had a hard time in finding a way to read BIGTIFF files. In the end I only managed to do so by creating a new conda environment with the following options: conda create -n env_name ...
1
vote
2answers
256 views

Overlay two raster GeoTIFFs using rasterio mask

I'm trying to crop two different geotiffs/rasters using a polygon with rasterio's mask function in order to get two corresponding/overlapping cropped numpy arrays of the same size/shape. The problem ...
1
vote
0answers
41 views

Rasterio 0-360 lon inputfile to -180:180lon WarpedVRT output

I have used rasterio to open netcdf files and by defining a WarpedVRT extract a subarea that can be read with the vrt.read() command. It works like a charm except when the longitude grid is 0:360 ...
1
vote
0answers
409 views

Installing Rasterio and GDAL API in a virtuallenv in Windows 10

Following rasterio installation guidelines (rasterio.readthedocs.io) I downloaded the relevant wheel files from Cristoph's list (link) and installed them successfully on my Windows 10 system. Yet I ...
1
vote
0answers
93 views

Alternative to Rasterio Mask module for clipping a raster using masked geojson

I am clipping a raster (.tif file) using a mask vector (.geojson) file. with rasterio.open(url) as src: out_image, out_transform = rasterio.mask.mask(src, shapes, crop=True) But, this ...
1
vote
0answers
105 views

Reprojection problem with Rasterio

I have already processed so far NDSI map by using Rrasterio, NumPy, os and matplotlib.pyplot for plotting the data. Now, I would like to eliminate permanent ice from NDSI map. I am facing one major ...
1
vote
0answers
35 views

Getting subset with same cordinates for different rasters using gdal.translate?

I am a new into Python. I have processed 1000 NDVI rasters covering larger area. I need to burn those NDVI raster with Water mask. The water mask came for whole world I need to subset AOI and also ...
1
vote
1answer
41 views

Cut hole in raster with shapefile and sample at closest edges

I have a raster in which I'd like to cut a "hole" with a shapefile. I have points close to the boundary, but inside the hole, and I would like to find the closest point on the edge. To give a concrete ...
1
vote
0answers
216 views

Plotting TIFF File on tkinter Canvas

I have a TIFF file which I am trying to plot on tkinter canvas using the following code: import tkinter from matplotlib.backends.backend_tkagg import ( FigureCanvasTkAgg, NavigationToolbar2Tk) # ...
1
vote
0answers
51 views

GDAL or rasterio to find minimum extent of multple files in command line

I have two files, GeoTIFFs (.tif) in this case which need to be cropped to each other's minimum overlap, and have matching spatial resolutions. I also want to round their Pixel Size to a whole number (...
1
vote
0answers
67 views

Calculate transform from oblique raster, shape and CRS

Given a simple jpg of an oblique aerial photography, the geometry and a CRS I am trying to determine its affine transform so I can convert it into a GeoTIFF. import rasterio, rasterio.crs raster = ...
1
vote
0answers
279 views

Faster zonal stats for equal rasters with Python

I'm trying to extract data out of many raster images with different bounding boxes. Using the great rasterstats.zonal_stats it's a good approach, but it takes a considerable amount of time, especially ...
1
vote
0answers
249 views

Resolving CRS Error in rasterio

I am trying to use the pysheds package to calculate flow accumulation from a DEM. However, when reading the DEM .tif-file, I get the following error. I can't find any more information as to what this ...
1
vote
0answers
115 views

Reading a RasterIO MemoryFile triggers a GTiff driver warning/error message

I have recently upgraded RasterIO from version 1.0.5 to 1.0.12. After this upgrade I now get CPLE_NotSupported in driver GTiff does not support open option MODE when reading a MemoryFile. My code to ...
1
vote
0answers
108 views

Summarising all the (NDVI) values pixelwise for a masked polygon

A .tif image has been created using the NDVI formula in QGIS. The resulting image shows a region, with varying grades of NDVI values over the image. A .shp file has then been created for an area of ...
1
vote
0answers
58 views

Geologica data UDM(unusable data mask) have 8 bits per pixel

UNUSABLE DATA MASK FILE(UDM) The unusable data mask file provides information on areas of unusable data within an image (e.g. cloud and non-imaged areas). The pixel size after orthorectification ...
1
vote
0answers
335 views

Polygonizing raster cells in rasterio regardless of value?

I would like to polygonize every single cell of a raster dataset using rasterio. I have been experimenting with the following function based on this question: def polygonize_raster(dataset): # ...
1
vote
0answers
709 views

Writing numpy array to rasterio raster file generates empty file

I'm using Rasterio to read GeoTIFF from Sentinel 2 and calculating NDVI, but when I try to save as a new TIF file, the file turns to transparent and empty file. What am I missing? That's the code: ...
1
vote
0answers
92 views

rasterio & cogeo

I am trying to use rasterio to read cloud-optimized geotiff stored in a gc bucket. With method 1, GDAL makes use of the overviews and read is quick. Unfortunately, if the extent is not fully included ...
1
vote
0answers
827 views

Rasterio Raster merge - horrible result

I am merging .DEM files from CUGIR NY repository, and need to merge files into one larger image for the whole of NY city. I use python 3.6 + rasterio; It works perfectly for all but one file - "The ...
1
vote
0answers
89 views

rasterize gradient from shapely object with rasterio

I have an array of horizontal and non-horizontal 3d-polygons as shapely objects, and I want to rasterize them into a depth map For horizontal ones, it's just drawing their height as color, but I ...
1
vote
0answers
129 views

Does anyone know why I'm getting a completely black geotiff as a result of this shapefile cut out of another geotiff in rasterio?

I am using rasterio to cut out the shape of a lake outlined in my shapefile from a geotiff. When using a shapefile of a singular lake with a geotiff, this works perfectly, but not when cutting out a ...