Clean and fast and geospatial raster I/O for Python programmers who use Numpy
Questions tagged [rasterio]
440 questions
3
votes
0 answers
ModuleNotFoundError: No module named 'rasterio' even It is installed from the cmd
I'm using Python 3.7.2 and Pycharm as an IDE. I'm trying to import the rasterio packages but its gives me an error in Pycharm ModuleNotFoundError: No module named 'rasterio'. Even I have installed it from the cmd with the GDAL as it is mentioned…

M.Yassine
- 31
- 5
3
votes
2 answers
Using matplotlib and Rasterio I am trying to save a raster as a GeoTIFF as well as repoject it?
I have been able to plot and display my raster images using matplotlib. That part is successful. The part which I am stuck on is be able to save that plot somehow. For rasterio I've found two helpful…

yuen2
- 79
- 1
- 2
- 7
3
votes
1 answer
Installing Rasterio on Ubuntu fails with ImportError
I have an AWS EC2 p2.xlarge instance running on Ubuntu 16.04.4 LTS that was created using the AWS Deep Learning AMI (DLAMI). I am using the keras/Tensor Flow conda environment:
$ source activate tensorflow_p36
I am attempting to install Rasterio…

Borealis
- 8,044
- 17
- 64
- 112
3
votes
1 answer
Spatial reference missing from rasterio write to GeoTiff
I am trying to use rasterio to load in an image, modify the ndarray, then write out using the same spatial reference system as the original image. The below function is my attempt to do this. But the spatial reference system is missing from the…

nicway
- 538
- 1
- 6
- 16
3
votes
1 answer
ST_PixelAsPolygons rasterio
Is there a way to perform a similar function such as ST_PixelAsPolygons using rasterio?
I am aware of rasterio.features.shapes but that would output the shape of similar pixels instead of the geometry of all pixels. How could I get the polygons and…

Olga
- 33
- 4
3
votes
0 answers
rasterio - mask raster against shape, with all pixels completely inside shape
I'm cutting a tiff file against a given shape, to filter the pixels inside.
I'm using rasterio to do it like this:
mask = rasterio.mask.mask(tiff, geoms, crop=True, all_touched=False)
This works but doesn't yield exactly what I want (which is: give…

Tony Lâmpada
- 5,301
- 6
- 38
- 50
3
votes
3 answers
Import module (rasterio) fail with conda or pip install
I am trying to install rasterio into my python environment and am getting the following errors. I can do
conda install rasterio
No error comes up on the install but I come up with the following error when I try to import
from…

rick debbout
- 439
- 2
- 5
- 19
2
votes
1 answer
How to assign specific color to a category in an array
I want to show the land use classes of a region.
I have different raster files that contain information of land use. Each value of the pixel correspond to a specific land use class. I want to assign to each class a color as shown below. This is what…

emax
- 6,965
- 19
- 74
- 141
2
votes
1 answer
Rasterio Driver Registration
I'm trying to explore/pre-process some of the USGS's landsat data. currently I have downloaded two scenes through python's pylandsat module. These scenes are:
LE07_L1TP_205050_19991104_20170216_01_T1
LE07_L1TP_206050_19991111_20170216_01_T1
I…

jpate24
- 21
- 1
2
votes
1 answer
Suppress RasterIO Warning. Warning 1: TIFFReadDirectory
I've been having problems with the error message
Warning 1: TIFFReadDirectory:Sum of Photometric type-related color channels and ExtraSamples doesn't match SamplesPerPixel. Defining non-color channels as ExtraSamples.
This error message occurs when…

BananaJoe
- 55
- 6
2
votes
1 answer
numpy-based spatial reduction
I'm looking for a flexible fast method for computing a custom reduction on an np.array using a square non-overlapping window. e.g.,
array([[4, 7, 2, 0],
[4, 9, 4, 2],
[2, 8, 8, 8],
[6, 3, 5, 8]])
let's say I want the np.max,…

cefect
- 88
- 6
2
votes
1 answer
Geotiff Image upside down in python
I have converted a NetCDF file to Geotiff. However when I display the Geotiff file it appears flipped or upside down. Here is my code:
import xarray as xr
import rioxarray as rio
import rasterio
nc_file =…

Nishita
- 37
- 1
- 3
2
votes
1 answer
"ValueError: Array conditional must be same shape as self"
I am trying to follow a tutorial. Basically, I want to run random forest classification on my 31-band Sentinel 1 and Sentinel 2 stacked image. Also, I want to extract raster values to my training-testing shapefiles. This is what I tried:
from osgeo…

Gulnihal
- 76
- 6
2
votes
0 answers
Python - georeference png image to geojson of polygons
I have a folder of multiple png images of the same map. The map is on country level and consists of administrative polygons. I have the geojson for this and I want to georeference programmatically, with Python, all of these images to the geojson and…

lios
- 218
- 5
- 26
2
votes
2 answers
How to add time dimension and create an xarray dataset/data array from a stack of rasters?
I have approximately 75 2D raster maps (tifs) of elevation over the exact same area, each acquired at a different time. I would like to stack these using xarray. I can read in each raster (see below) but currently, there is no time coords as I need…

wmitchell93
- 41
- 7