Questions tagged [rasterio]

open source Python library for reading and writing geospatial raster data

Filter by
Sorted by
Tagged with
1
vote
1answer
43 views

How do I avoid altering the data range when writing a NumPy array into a TIF file with rasterio?

I'm using a machine learning model to automatically recognize (a specific type of) vegetation in RGB imagery. The output of this model is a binary NumPy 2d array, with '1' meaning vegetation and '0' ...
1
vote
1answer
36 views

Adding datetime to each band's metadata in a multiband raster using Python

I've created a multiband raster of individual rasters of temperature at different times over a period of two days using rasterio in the following way: with rasterio.open('test.tif', 'w', **meta) as ...
0
votes
1answer
21 views

Reading a raster with window with overlap

I have a raster 50000x50000 pixels. I want to iterate a window of 1000x1000 pixel on it with some overlap and apply bilateral filtering. I want to save the resulting filtered patches into a mosaic ...
3
votes
1answer
38 views

Calculate the sine of a raster in the power of y / Python

I have this code and my aim is to calculate the sine of my raster in the power of 0.8. import os os.chdir('D:/NOA/Soil_Erosion/test_Project/Workspace/Input_Data_LS_Factor') import rasterio ...
0
votes
0answers
22 views

Rasterio projection woes converting raster to vectorized GeoJSON polygons using GDAL and OGR

Can anyone explain what I am doing wrong here: why my latitude coordinates are erroneously offset by about 20 miles when I go through this procedure: I create a raster called map_dataset using ...
0
votes
1answer
45 views

Convert from latitude, longitude to geoTIFF screen pixel x,y coordinates in Python

I'm trying to use rasterio or pyproj to convert latitude and longitudes into the SCREEN xy coordinates of a geotiff, so that I can superimpose 2D objects on it in a raster plotting library. ...
2
votes
0answers
21 views

How to resample the raster cells to make a merge (mosaic)?

I am creating a DEM with raster files, but I would like to downsample the pixel values (resampling to lower resolution/larger cell sizes) in order to reduce the size of my generated file. My idea is ...
0
votes
0answers
31 views

Writing raster file from masked array

I am doing some raster subtraction to get a canopy height model and I am struggling to write the output as a raster. The original datasets were .tif files in ESPG 27700 created from LiDAR. I used ...
1
vote
1answer
33 views

Python: How to specify crs of raster file by Python/rasterio?

I use the rasterio to cut out roofs of buildings, roofs are polygons. I would like to set up crs of felled roofs. Is it possible to do that by rasterio? I can set up crs of layer, layer.crs = 'epsg:...
1
vote
2answers
52 views

How to find coordinates of pixels of a GeoTIFF image with Python

I have a GeoTIFF image that looks like the following f = rxr.open_rasterio('myFile.tif') f5 = f.sel(band=5) f5.plot.imshow() I would like to create a Pandas dataframe with the values of each pixel ...
0
votes
1answer
54 views

Raster Subtraction using rasterio or gdal

I'm beginner to python. Each directory has two rasters named A.tiff and B.tiff. I need to subtract B.tiff from A.tiff and store the resultant file in the same directory. The directory paths are named ...
2
votes
0answers
39 views

Very slow segmentation using Python

I used both Python and QGIS to perform polygonization of a raster but the waiting times with Python are very long, while with QGIS the operation is done in a few seconds. Could you tell me the reason ...
0
votes
0answers
56 views

Plotting Landsat Image on Folium Maps

By using the following code I am trying to plot Landsat 8 RGB image onto the folium maps. Following is the code: import rasterio as rio import folium from pyproj import Transformer ## LC08 RGB Image ...
0
votes
1answer
44 views

Rotating GeoTIFF images

I have a GeoTIFF file which when imported using rasterio get flipped on the y-axis, and now I am trying to rotate this GeoTIFF file using NumPy rotate, it gives an error (Axes=(0, 1) out of range for ...
0
votes
0answers
20 views

PostGIS raster not loading in QGIS (version >3.10 on MacOS and Windows)

When loading PostGIS rasters (through the brower or via DBmanager) from my database into QGIS (LTR versions on both MacOS (Big Sur) and Windows 10), these fail to render. Either nothing shows up, or a ...
1
vote
1answer
41 views

Array memory error when reading rasters

I'm attempting to make a spatio-temporal statistics analysis on a few chunks of data using rasterstats, rasterio and pandas/geopandas on Python. # create dataframes for areas of interest and specify ...
3
votes
1answer
49 views

rasterstats zonal statistics does not ignore nodata

I am trying to write a script to perform some zonal statistics with rasterestats, but I am really struggling with nodata values. I noticed a different behaviour 1) when running zonal_stats with numpy ...
2
votes
0answers
32 views

Do PNG files suffer performance for scaled read over ERDAS Imagine (.img) files?

So I have a 20 GB in size Raster Image in .img format. Though I will be examining the code, to find out why, I am AMAZED at how quickly QGIS renders the entire file in a scaled format, and prior to ...
0
votes
0answers
14 views

High values when opening HDF bands in rasterio

Im getting very high values when opening a band in rasterio from an HDF file. I got the same thing when I open netcdf files. I guess the issue for netcdf is related here: (1) and (2) Thus when opening ...
0
votes
0answers
27 views

Mosaicing rasters Rasterio vs GDAL

I want to create a mosaic using multiple tiles. Firstly I've tried GDAL using gdalbuildvrt + gdal_translate commands. Then I wanted to use Rasterio for creating mosaics. I've used rasterio.merge.merge ...
1
vote
1answer
63 views

Get the correct transform from bounding box with Rasterio

I have image as numpy array with no projection or geographical data and I have information of the bouding box of this numpy array (the image suppose to match perfectly the bbox). The bbox is ...
0
votes
0answers
17 views

set CRS for numpy array that has no geographical data using rasterio and bbox data [duplicate]

I have 1 dimension numpy array that has no geographical information. The numpy array was originally satellite image that I have manipulated in order to get this 1 dimension arrray. I have the crs and ...
0
votes
2answers
131 views

Set CRS to numpy array with no geographical data using rasterio

I have 1 dimension numpy array that has no geographical information. The numpy array was originally satellite image that I have manipulated in order to get this 1 dimension array. I have the crs and ...
0
votes
1answer
28 views

Is it possible to build a .vrt file from multiple files with Rasterio?

I would like to build a vrt file from multiple dataset. I know the gdalbuildvrt but i don't find how I'm supposed to do the same using rasterio vrt object. Does anyone have a simple example ?
0
votes
2answers
34 views

How to mask and scale raster using rasterio?

I have been trying to read a raster file in netcdf format which I will later on sample. I need to read using the DatasetReader as float. When I read: ds = rasterio.open(f'netcdf:{file}:AOT_L2_Mean', ...
1
vote
1answer
39 views

No data found in bounds using rioxarray to clip GeoTiff to shapefile

I get the following error when trying to clip a GeoTiff to a shapefile: "No data found in bounds." Steps to reproduce: import rioxarray as riox rain = riox.open_rasterio( "https://...
1
vote
1answer
28 views

How to get nanmean of each pixel in multiple raster image?

I wrote a code based from rasterio and numpy that gets the nanmean of every pixel from multiple of raster images. I first read it using rasterio, then I convert the array to float32 so that I can set ...
0
votes
0answers
19 views

Problem with CRS and proj.db using Reproject from Rasterio

I saw similar problems but I still can't manage with mine. Some technical information: I've installed rasterio version via anaconda (conda install rasterio): rasterio-1.2.1-cp37-cp37m-win_amd64.whl ...
1
vote
0answers
14 views

How to cut out the polygon if stands at two tiffs?

I would like to cut out the polygon from tiff. The problem is that the polygon stands on two tiffs. I was thinking about the solution and I can create a raster mosaic from 2 tiffs. Is it good idea or ...
0
votes
2answers
38 views

Rasterio read outshape resample does not give correct array

I have a population grid and want to decrease the resolution by a factor 2. So I would like to get a raster that has 2 times less rows and columns, a resolution that is 2 times as large as the ...
1
vote
1answer
57 views

How to convert from HDF5 to GeoTIFF with Python

I'm coming from Reading metadata in HDF5 file. I have a HDF5 file with some radar information. I'd like to read this data and geospatial metadata contained in the file to produce a GeoTIFF. Using the ...
0
votes
0answers
16 views

Python: rasterio how to cut out a roof with bigger buffor?

I have done the code which cuts out the roof of the building from the tiff file. The problem is that the program is too precise. I would like to cut out the roof with bigger buffor. What should I ...
0
votes
0answers
20 views

Save an 8 band raster in one TIFF rasterio

I'm trying to write an 8 band image in just one TIFF using rasterio. I actually opened an 8 band raster, normalize it for further processing and tried to re-write the normalized bands: I used with ...
4
votes
0answers
80 views

How to index and load a time-stacked NetCDF file with Open Data Cube?

Our use case is to make a time-stacked NetCDF file accessible via Open Data Cube. Each NetCDF file (CMEMS data) has a time coordinate variable, with 8 time points evenly distributed over a range of ...
0
votes
0answers
29 views

Georeference an image in WGS84 where I have the center lat/lon and image dimensions

I have a drone image which I have warped into the proper orientation and shape and now I'm trying to georeference this image. My image pixels are 0.2 meters, my image dimensions are 750x750 pixels, ...
0
votes
1answer
24 views

Positional argument error using rasterio to reduce raster pixel size

I'm new with rasterio and I need to reduce the pixel size of a GeoTiff. Using the code below def resample(input_raster: str, output_raster: str = None): upscale_factor = 2 with rasterio.open(...
0
votes
0answers
33 views

Rasterio reprojection, changing pixel size: results in crazy pixel values

I'm trying to project a geotiff with 789x789m pixel size to 100mx100m using another geotiff as a template. Everything seems to work except that the output pixel values, shown when I open the file in ...
0
votes
1answer
30 views

Match a list of shapefile names to list of raster names then do something

I have a list of shapefiles and a list of rasters that I would like to match the names then do some data extraction for later analysis. The beginning of each raster and shapefile begins with "...
1
vote
1answer
79 views

Crop a raster image with the coordinates in a CSV file in Python

I am trying to crop a satellite image with geographical coordinate from a CVS file. I have never cropped an image using coordinates from CSV file. I tried searching a lot but I can only find cropping ...
0
votes
1answer
30 views

Reading CRS and Affine transformation from a NetCDF with CF conventions

I have a NetCDF with geographical information. I'd like to obtain a GeoTIFF file with rasterio. The problem is how to translate the geographical information from CF standard to something that GeoTIFF ...
1
vote
1answer
45 views

Creating a grid from pixels of a georaster in Python with GeoPandas

Let say we have a georaster file with a given resolution. Is is possible to create a grid where each cell of the grid correspond to each pixel? Is it possible to store this grid as a GeoPandas ...
0
votes
0answers
49 views

Georeferencing a GeoTIFF using with RasterIO

I am trying to Co-register a raster using Ground Control Points w.r.t. another raster using RasterIO. I have written a PoC, but having a bit of difficulty in measuring the quality of the final ...
0
votes
0answers
36 views

Width and value problems with rasterstats

I am trying to extract data from a raster with a gpkg file as a vector. The issue is that, the data can't be extracted because the internal Bounding Box is negative. There I am not sure, whether this ...
1
vote
0answers
22 views

Get coordinates of all pixels in a raster with rasterio

I have a n by m raster image in rasterio and I would like to get the ground coordinates of all the pixels in this raster (ideally in an array of tuples). What would be an efficient way to do this? ...
0
votes
0answers
19 views

Adjusting pixel values of a raster based on geopandas colums or fields

I have a geodataframe with geometry column containing Polygons and 5 fields or columns('Crop1', 'Crop2', 'Crop3', 'Crop4' and 'Crop5') as well as a raster image. There are 159 rows in the geodataframe ...
2
votes
1answer
73 views

Plot histogram with rasterio

This is not something I do often, but I recall it being fairly easy. Today however I can't make it work: Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] on linux Type "help", &...
0
votes
2answers
54 views

How to put GeoJSON coordinates to TIFF?

I have GeoJSON coord: {"type":"FeatureCollection", "features":[{"type":"Feature","properties":{},"geometry":{"type":&...
0
votes
0answers
50 views

Clipping ENVI files loses information in header (.hdr) file

I have created a command-line operated python-script to cut AVIRIS imagery with polygons. I do this by using rasterio to load the imagery and fiona to load the polygon. The AVIRIS imagery comes in two ...
0
votes
0answers
58 views

How to work around rasterio installation issue below

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 ...
2
votes
1answer
80 views

Export numpy array as TIFF with rasterio fail with the folder name :No such file or directory

I experienced unexpected behaviour of rasterio and I couldn't understand yet where is my mistake. I have opened rasterio TIFF, did some manipulations on it as numpy array and then export it as TIFF ...

1
2 3 4 5
11