Questions tagged [rasterio]

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

Filter by
Sorted by
Tagged with
-1
votes
0answers
18 views

How should I use a conda-forge environment? [on hold]

A month ago I raised a question here because I couldn't (and I still can't) read BigTIFF raster files with gdal/rasterio ("RasterioIOError: This is a BigTIFF file. BigTIFF is not supported by ...
2
votes
0answers
19 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 ##...
0
votes
0answers
14 views

ImportError: libkea.so.1.4.7: rasterio

I am working in Tethys platform. I am trying to use rasterstats module for getting min max for a raster data with in an AOI(area of Interest). from rasterstats import zonal_stats when I use this ...
0
votes
0answers
58 views

Installing rasterio and Fiona together?

I work on Windows; I use Christoph Gohlke wheels; Python 3.7 After installing GDAL-3.0.1 and Fiona-1.8.6 an error occurs on import of fiona from fiona.ogrext import Iterator, ItemsIterator, ...
0
votes
0answers
27 views

rasterio rasterize does not take geometry

rasterize(allshapes) return; "ValueError: No valid geometry objects found for rasterize" Testung a single shape: print(shape.GetGeomFieldRef(0)) POINT (56.91288 27.33519) print(is_valid_geom(...
0
votes
0answers
12 views

Mimik -crop_to_cutline from gdalwarp with rasterio.mask

I'm trying to clip a raster with some polygons, some of them lie party outside of the raster. In gdalwarp, if you set -crop_to_cutline, it will fill the exterior part with no data and make it be a ...
2
votes
1answer
30 views

What data structure to use for raster data when using rasterio?

I want to write a method in Python that reads a raster (GTiff) using rasterio and returns its contents. Then, some processing is done. Finally, I want to write the data to a new GeoTiff. As far as I ...
0
votes
0answers
20 views

Permissions are blank when trying to load satellite images from Planet API

I am trying to download the map of Melbourne using Planet API. I have given AOI coordinates of Melbourne. When I run the code the permissions are returning blank ("_permissions": []). I cannot able to ...
1
vote
0answers
31 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) # ...
0
votes
0answers
27 views

Creating a raster file with multiple attributes from numpy arrays?

I have 2 numpy arrays (same dimension) which I would like to use to create a TIF raster file with 2 attributes. I'm trying to do so with rasterio with the following piece of code: out_meta = ..... ...
0
votes
0answers
25 views

Plotting Raster Data on tkinter canvas using Rasterio

I am trying to plot my Raster Data on tkinter canvas using the following code: import tkinter from matplotlib.backends.backend_tkagg import ( FigureCanvasTkAgg, NavigationToolbar2Tk) # Implement ...
1
vote
1answer
29 views

Creating an in-memory raster with rasterio

Note that this is not the same as Creating an in memory rasterio Dataset from numpy array. Currently I have a workflow which creates a "template raster" from which other rasters are derived. However, ...
3
votes
2answers
61 views

Upscaling Raster Data in Python

Solved @user2856 helped me crack this. import geopandas as gpd import rasterio as rio from rasterio import features from rasterio import Affine from rasterio.enums import Resampling results = [] ...
2
votes
0answers
108 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: "...
1
vote
0answers
37 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 (...
0
votes
0answers
19 views

Python code error when making fusion of multispectral image and DEM

I tried to fuse 4 multispectral bands from Landsat 8 with resampled SRTM, Aspect, Slope. It should contain 7 bands: R,G,B,NIR,DEM,Aspect,Slope. The code execution generates output raster, MS bands are ...
1
vote
0answers
30 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 = ...
2
votes
1answer
95 views

Should resampling/downsampling a raster (using Rasterio) cause the coordinates to change?

I was able to successfully downsample a raster file, after getting Stack Exchange help. I loaded the new downsampled file into QGIS along with the original file, to check that things went well. The ...
2
votes
1answer
97 views

Rasterio - save multiband raster to TIFF file

I was trying to get Rasterio to save a 3 band raster to a TIFF file. For some reason, the example in the documentation only shows how to save raster with only 1 band. Now when I tried to save a 3 band ...
1
vote
1answer
64 views

Rasterio resampling image to lower resolution error: 'float' object cannot be interpreted as an integer

I am trying to downsample a raster image to a lower resolution using rasterio. I am running into an error about 'float' object cannot be interpreted as an integer and I can't seem to figure out the ...
0
votes
1answer
39 views

Error when updating a raster file with a numpy array using rasterio.write

I'm iterating through thousands of polygons. Each polygon clips a tif raster producing a numpy array. Then the numpy array values are manipulated and the tif raster is updated with those new values. ...
1
vote
0answers
87 views

Converting a raster pixel by pixel to vector cells in Python

Problem Today I needed to convert raster to a shapefile with rectangular polygons representing each pixel of the raster in Python, including the pixels with value 0. Related questions: Converting ...
3
votes
1answer
173 views

Creating an in memory rasterio Dataset from numpy array

I am reading in a raster using rasterio, and then upsampling the raster as per the example in the documentation: def upsample_raster(raster): return raster.read( out_shape=(raster.height *...
1
vote
1answer
45 views

How to not overwrite with NoData values when updating a raster file using a numpy array?

I have a numpy array (called out_window) with the following values: out_window: [[[499 498 481] [494 490 464] [483 480 -1] [482 -1 -1]]] This numpy array was obtained by clipping a raster ...
1
vote
1answer
52 views

Updating a subset of raster values using open source Python (rasterio, for instance)?

I have a source raster data set (tif file) and a number of polygon features. For each one of those polygons I need to: a) 'clip' the raster. b) change values of those clipped raster cells (with the ...
0
votes
1answer
89 views

Reprojecting data with GeoPandas using 'to_crs'?

I am trying to reproject a polygon so that it has the same projection than a raster dataset. raster.crs CRS({'proj': 'tmerc', 'lat_0': 0, 'lon_0': -183, 'k': 0.9996, 'x_0': 500000, 'y_0': 0, 'datum': ...
1
vote
0answers
58 views

Raster nodata = -3.4028234663852886e+38 [closed]

I'm very new to raster manipulation, and I'm getting a nodata value of -3.4028234663852886e+38 when importing USGS NED 1/3 arc-second n41w074 1 x 1 degree IMG using rasterio on Python. What is it ...
1
vote
1answer
63 views

Get Row/Column of Latitude/Longitude

I downloaded Sentinel-2 Imagery from AWS & I'm using rasterio to read/manipulate the data. I want to find the row/column coordinate of a latitude/longitude point that I initially used to search ...
4
votes
1answer
98 views

Extracting data within geometry (shape)

I have a NetCDF dataset which I normally call using the xarray function. I have recently been doing some transect analysis on the dataset, which looks something like this (the area between the ...
1
vote
0answers
75 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 ...
2
votes
0answers
82 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 ...
1
vote
0answers
101 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 ...
0
votes
0answers
21 views

How to add an extra layer of values to Sentinel 2 data

I'm working on Sentinel-2 data on water bodies. I collected the bathymetry information of a particular lake(which is having x,y,z. ie lat long and depth). Now I want to superimpose those depth values ...
0
votes
1answer
79 views

Transforming a image to a shape defined by image corners in earth coordinates - Python

I have a source satellite image. It is a rectangular shape x by y. I also have the stored lon/lat coordinates of the corners and the center point in the xml meta file. Is there a way with the gdal or ...
1
vote
1answer
150 views

How to downsample raster image for nightlights data in Python?

I'm working with the nightlights data - 30 arc second grids, spanning -180 to 180 degrees longitude and -65 to 75 degrees latitude. I want to downsample it to 5 arc-min resolution. Now my question is ...
3
votes
1answer
93 views

Re-project GeoJSON from pixel-space to lat-long in Python

I have created a GeoJSON of linestrings in pixel space using Python. However, I now need to re-project the file to match the same projections and extent of the .tiff file I wish to layer the GeoJSON ...
3
votes
1answer
108 views

Error using rasterio's sample method

I'm using rasterio's sample function to get values from a (single-layer) raster based on a list of x,y locations: for val in myraster.sample(locations): print(val) This works fine for the first ...
3
votes
1answer
398 views

Converting NetCDF dataset array to GeoTiff using rasterio Python

I have read a NetCDF file using the netCDF4 library and then read one of its datasets ("Evapotranspiration") into a variable (variable contains array) using the following code. Subsequently now I am ...
1
vote
1answer
149 views

Python rasterio for saving GeoTIFF files and read in ArcGIS or QGIS

After following the steps in the tutorial of the Planet website (https://developers.planet.com/tutorials/convert-planetscope-imagery-from-radiance-to-reflectance/), I want to save each individual band ...
0
votes
1answer
153 views

Python rasterio save GeoTIFF files

After following the steps in the tutorial of the Planet website (https://developers.planet.com/tutorials/convert-planetscope-imagery-from-radiance-to-reflectance/), I want to save each individual band ...
4
votes
1answer
273 views

Rasterizing polygon grid in Python (geopandas & rasterio)

I am trying to rasterize a custom polygon grid with one or more columns. Preferably I'd like to create multi-band rasters from multiple GeoDataFrame columns (in polygon grid), but I have got stuck ...
0
votes
1answer
306 views

Writing a 3-band image with rasterio

I would like to save a 3-band raster to file using rasterio. The official docs have examples for saving a single band image in both the quickstart and in the advanced topics. What I would like to do ...
1
vote
1answer
173 views

Opening .vrt file with rasterio in Python?

I have 3 raster files (.tiff files) which are geographically 3 consecutive tiles of a particular area. I am trying to make a .vrt file of 2 out of these 3 files using the gdalbuildvrt python command. ...
0
votes
0answers
110 views

Plotting Multiple Rasters on Tkinter Canvas?

I have 2 Raster data sets (raster 1, raster 2) which are spatially adjacent to each other. As of now I am able to display individual raster on the tkinter canvas without any issues. What I am looking ...
1
vote
2answers
84 views

Storing image with rasterio as gtiff modifies image histogram

I'm trying to store and image as as gtiff, but the resulting image is changed, and I can't explain why. I'm reading sentinel jp2 band images using rasterio, I rescale these images from [0-10.000] to [...
2
votes
1answer
141 views

Sum the value of two raster files using Rasterio (Rasterio equivalent of Raster Calculator from ArcGIS)? [closed]

I'm trying to calculate the "real height" of a region, meaning I want to sum the elevation value and building height value, if there is any building, for a region. I know I can simply use Raster ...
1
vote
2answers
120 views

Resampling Sentinel-1 to Landsat 8 size and location

I am training a convolutional neural network to classify landcover and I would like to ingest both Landsat 8 and Sentinel-1 into my classifier. Currently it is working reasonably well for Landsat 8 ...
0
votes
1answer
174 views

Change CRS of large GeoTIFF and extract windows from large raster in Python

This is the first time I am working with GeoTIFF formats and I want to do this in Python. I am trying to use rasterio and pyproj for the following tasks. I have already made some first steps based on ...
1
vote
1answer
62 views

Open a mutliband raster, edit values in one of the bands, and overwrite the raster using Python/Rasterio?

I have numerous multiband rasters (36 band) in which preserving the band order is important for future processing. One of the bands often contains erroneous data and I'd like to be able to change all ...
1
vote
2answers
77 views

Automating calculation of NDVI with rasterio?

I want to automate this code below for other 99 images, the problem that I have is that each image is in its specific folder as it's mentioned in the picture below. the images are very big and I want ...