Questions tagged [rasterio]

open source Python library for reading and writing geospatial raster data

Filter by
Sorted by
Tagged with
0 votes
0 answers
14 views

Resample using Rasterio with Resampling.sum method

I want to resample Geotiff image using Rasterio with Resampling.sum I have the following code, however, it returns, ResamplingAlgorithmError: <Resampling.sum: 13> can be used for warp ...
Sang Truong's user avatar
2 votes
1 answer
111 views

Polygonize error

I try to vectorize raster layer. Each pixel has value from 1 to 128. It the simplest and has only 1 band. I use polygonize tool and I get an error. Initially I got my raster from rasterize tool (...
grassu's user avatar
  • 53
1 vote
2 answers
41 views

How to pass GDAL CLI arguments when exporting a GeoTIFF with rioxarray

I have a routine that create a mosaic from COPDEM 30M and I need to export it passing an argument to it. The argument: -mo AREA_OR_POINT=AREA --config GTIFF_POINT_GEO_IGNORE True The behavior I expect ...
Rik Ferreira's user avatar
0 votes
1 answer
62 views

How to change the extent of an existing TIFF given shapefile bounding extent using rasterio's projection

I'm currently trying to figure out how to re-create the following method using rasterio's reprojection method. Currently in R there is a way to extend an existing GeoTIFF's extent using bounding ...
h0mer's user avatar
  • 103
1 vote
0 answers
38 views

Rasterio convert vertical datum of NAVD88 to WSG84

I've been asked to provide an elevation data for projected to GPS. To achieve that i've tried to convert the NAD83 geotiff with NAVD88 vertical datum (downloaded from USGS) into WSG84. To do the ...
Szymson's user avatar
  • 11
1 vote
1 answer
33 views

While exporting the rasters using rioxarray, nodata value is undefined after the mask

I have used xarray to open the netcdf file, and using rioxarray exported the raster as a .tif file. However, the exported raster doesn't have definition for nodata value, and hence, the GIS software ...
hillsonghimire's user avatar
0 votes
0 answers
36 views

QGIS rasterize with field as value, outcome only captures part of values in the field

I have a vector file with multiple polygons with a column named all_cert. I want to rasterize this data but everytime I do, the resulting raster file only contains pixels with values for certain areas ...
Evelina's user avatar
0 votes
2 answers
47 views

Rasterio & rioxarray no longer compatible with fairly standard modules

I just bought a new computer and want to read a geotiff and plot it in cartopy. I'm typing: conda create --name my_env conda activate my_env conda install numpy pandas jupyter cartopy xarray ...
Robbie Mallett's user avatar
0 votes
1 answer
38 views

Rasterio ValueError

I am trying to clip a bunch of Landsat images with vector mask, but the Rasterio keeps hitting me with following error: ValueError: min() arg is an empty sequence I have not been able to resolve it....
Catallena's user avatar
1 vote
1 answer
91 views

Skewed NDVI values

I'm analyzing open-source NIR images with Python. I'm a novice to remote-sensing and have a doubt about my NDVI results. I calculate my NDVI like so: with rasterio.open(self.tif_path) as src: ...
Michael S's user avatar
1 vote
2 answers
65 views

Modify cells in a raster, that intersect or are inside a polygon without modify the other cells

I have a raster of a DEM (Digital Elevation Model with values in meters above sea level) in .tiff format, and I need to subtract the value of 10 from the elevation values of cells located within a ...
El Memo de Mileto's user avatar
0 votes
0 answers
110 views

Correctly merge Landsat images in a median mosaic using different tiles

I have several Landsat 8 and 9 images, from two different tiles that I want to merge together in a median mosaic. The tiles are tiles that overlap, with two images for each tile. What I'm doing to ...
rrwork___'s user avatar
0 votes
2 answers
46 views

Enlarge numpy array to fill/pad bounds in rasterio whilst keeping existing data intact

I'm looking to do what this question and answer is doing using gdal_translate / gdal_warp, but in Rasterio. Does anyone know of a way? I can't find anything in the rasterio.warp.reproject module that ...
Stev_k's user avatar
  • 6,689
1 vote
2 answers
98 views

Polygonize black areas (0) in raster

I have satellite imagery. Some of these images have black areas (zero values). I would like to polygonize the black areas. Is this possible using QGIS or rasterio?
Daniel AG's user avatar
1 vote
0 answers
49 views

Crop Sentinel-2 raster using a geometry leaves pixels around the edges

I want to crop Sentinel-2 images using a geometry. However, whenever I crop my image, there are some pixels around the border of the raster. For example, the image below is the band 2 of sentinel-2 ...
rrwork___'s user avatar
0 votes
0 answers
23 views

Warning during the clipping with rasterio mask

I am trying to clip raster with geodataframe geometry and save it according to the gid. So I have 150 polygons in the geodataframe and using the threading I am clipping each polygon and writing to the ...
Manap Shymyr's user avatar
0 votes
2 answers
59 views

From a raster (rasterio) to a geopanda at a polygon level [closed]

I'm currently working in a project that makes use of 2 datasets: A raster (geotiff) of nightlight intensity (only one band). A geopanda, where its geometries are polygons/multi-polygons My objective ...
pedrorosado's user avatar
1 vote
1 answer
59 views

Cloud detector s2cloudless run locally is masking non-cloud

I am trying to use the Cloud-detector on locally stored S2-Images in .SAFE format (L1C). I ran the cloud detector and the cloud mask that is returned comes completely wrong. Is there something wrong ...
rrwork___'s user avatar
0 votes
1 answer
121 views

Getting latitude and lontitude from TIF file using rasterio

I refer to link and want to get latitude and longitude from .tif file using rasterio. My code is the same as the answer: with rasterio.open(path) as src: band1 = src.read(1) print('...
wxystudio's user avatar
  • 119
0 votes
0 answers
21 views

How to unclip an image using rasterio?

I have a data transfer pipeline that is expecting an image in EPSG:4326 covering the whole world. The image I downloaded from my service provider is clipped to north America. Is there a way to ...
Pierrick Rambaud's user avatar
0 votes
0 answers
15 views

rasterio.mask.mask returning strange values

I am using rasterio.mask.mask to extract values from a raster based on a polygon feature: out_img, out_transform = mask(raster, feature, all_touched=True, crop=True, nodata=-999) Mostly it works ...
GlenS's user avatar
  • 519
1 vote
1 answer
53 views

Get results similar to Focal Statistics in ArcGIS at the same speed using Python

I am trying to run focal statistics in Python. The idea is to set a 1 square kilometers buffer (circular) around each pixel, then the percentage of certain type of pixels inside the buffer was ...
Larix Yang's user avatar
0 votes
1 answer
94 views

How to rasterize point data using average value per cell (not replace or add)

I have a geopandas.GeoDataFrame containing point observations that I would like to rasterize into a grid with a certain resolution, such that, for cells that contain multiple observations, the ...
lusk's user avatar
  • 111
1 vote
1 answer
151 views

Treat overlapping pixel when doing merge GeoTIFF images using Rasterio

I have a list of GeoTIFF images. I would like to merge these images together. However, as my understanding, it will take in turn the file and at overlapping pixels will receive the values from the ...
Sang Truong's user avatar
1 vote
1 answer
66 views

python: GDAL raster output is distorted

I'm trying to understand why my multiband raster output created with GDAL is distorted. Short summary: I got several hundreds of US counties data in csv format. For each one, I need to convert the CSV ...
Andrei Niță's user avatar
0 votes
0 answers
36 views

Visualization Issue when Overlapping Change Detection Map and Shapefile in Python using Rasterio and Matplotlib

I'm encountering a visualization problem while attempting to overlap a change detection map with a shapefile using Python, Rasterio, and Matplotlib. The change detection map is generated from a matrix ...
JCV's user avatar
  • 139
0 votes
1 answer
46 views

Python reshaping issues of 13 band TIFF to run through Random Forest classifier

I'm having some issues that I'm seeking help with. I have a 13 band TIFF and a trained random forest classifier with 13 features that are in the correct order to match the 13 bands. I haven't made it ...
mac754's user avatar
  • 11
2 votes
0 answers
52 views

Using rasterio to rasterize vector data to a GCP referenced image

I am working with Sentinel-1 SAR images of a coastal area in ground range geometry (GRD product), which is defined by a geolocation grid of 10×21 ground control points. For further analysis, I need to ...
Christoph's user avatar
  • 121
3 votes
1 answer
105 views

Counting how many times each pixel is covered in several GeoTIFFs

I have a few GeoTIFFs which might have overlap, I want to find how many times each pixel is covered in several GeoTIFFs. I thought it is best to create a heat map in Python (using GDAL or Rasterio) ...
Ari's user avatar
  • 33
0 votes
1 answer
62 views

Copying CRS from input file for writing to output file in Python without GDAL library

I'm using Python to process rasters that have a CRS. I want to copy the CRS to the raster that is produced. The rasters are like the following. Sorry, I don't know how to create this from scratch, ...
John Polo's user avatar
  • 377
1 vote
1 answer
92 views

Create multiband raster in Python from X, Y

How do you create a multiband raster in Python and save it as a .tif file from a long dataframe format? import pandas as pd import numpy as np from rasterio.crs import CRS import rasterio from ...
Andrei Niță's user avatar
0 votes
0 answers
99 views

Eliminate black border around nodata/alpha of GeoTIFF converted by rasterio

I have an image (png) that I want to place on a map: I use rasterio to georeference the picture: import rasterio as rio import warnings from pathlib import Path from typing import Tuple from rasterio....
Alex's user avatar
  • 714
0 votes
0 answers
101 views

Interpreting EPSG:4326 coordinates in a .tif file for a DEM

I am working on a piece of algorithm where I need to have access to ground altitude values from a digital elevation model. The model that I am using is SRTM1, which I access to by using the elevation ...
Ufuk Can Bicici's user avatar
0 votes
0 answers
35 views

Error in projecting a shapefile from CRS of ArcMap to a Proj4 string

I am trying to export the outputs of the National Water Model (https://github.com/NOAA-Big-Data-Program/bdp-data-docs/blob/main/nwm/README.md) inside of a basin using Python. With this code I called ...
ssaa's user avatar
  • 1
3 votes
1 answer
665 views

How to write PNG file from a raster using rasterio?

I have an image, which has 3 bands (RGB). I stack the image using numpy and try to write it as PNG. But I'm confused with how to work with the resulting image indexes. import rasterio import numpy as ...
Nikko's user avatar
  • 581
1 vote
1 answer
53 views

Raster is being saved with no bands names despite defining them using Rasterio

I have an ndarray which I would like to save as rasterio raster. I have all the information I needed (image size, transform, band names etc.). The problem is that when I try to save the image as ...
ReutKeller's user avatar
  • 2,107
1 vote
1 answer
264 views

How to get information of raster in rasterio similar to gdal?

I would like to print the raster statistics from its header. This can be done in gdal using the commands. gdalinfo dataset.tif or in Python bindings src = gdal.Open('dataset.tif') info = gdal.Info(...
Nikko's user avatar
  • 581
2 votes
1 answer
142 views

How to set NoData value to isolated pixels in Python

To reduce noise in a raster file, I aim to eliminate isolated pixels, those surrounded by NoData values in all eight neighboring positions. I have this code, but it is not removing those isolated ...
Isa's user avatar
  • 175
0 votes
1 answer
336 views

I am unable to open raster using rasterio

I am trying to open a raster file that I have downloaded using rasterio. It is a satellite image raster file of part of UBC in my data folder which I downloaded from Abacus Data Network. the However, ...
Williams Adaji-Agbane's user avatar
0 votes
0 answers
39 views

Reproject by Estimate_utm_crs()

If I am using function x.rio.reproject(x.rio.estimate_utm_crs()) then am I actually considering also parallels? The width and height of pixel changes with different longitude for me, however, The UTM ...
Luckasino's user avatar
  • 293
2 votes
1 answer
330 views

Opening a Sentinel 2 imagery from AWS servers using Python rasterio module

I am trying to access this file from S3 using Python's rasterio: "s3://sentinel-cogs/sentinel-s2-l2a-cogs/36/N/YF/2023/6/S2B_36NYF_20230605_0_L2A/" I will be using these two bands : B08.tif(...
BenStone's user avatar
  • 333
0 votes
1 answer
128 views

Rasterio Affine Transformation - Inverted

I am trying to understand how to properly set up an affine transformation using Rasterio. I have read through guides online and I have used the format provided but for some reason, it does not seem to ...
JMurfitt's user avatar
0 votes
0 answers
64 views

Correct Format for Transformation Rastio - from_origin

I am attempting to translate an HDF image to a GeoTIFF file and I encountered an issue when working with the transform module from rasterio. The issue comes when defining the transformation using '...
JMurfitt's user avatar
0 votes
1 answer
156 views

Rasterio DatasetIOShapeError: Dataset indexes and destination buffer are mismatched

I am trying to merge multiple .tiff files into a mosaic using Rasterio. tiles_to_merge = [] for id in tile_ids: tile = rasterio.open('../data/planet/' + id + '.tiff') tiles_to_merge.append(...
p017's user avatar
  • 1
1 vote
1 answer
245 views

Getting UTM coordinates from TIFF

I am trying to extract UTM coordinates (in meters) of every pixel in a TIFF file using the following syntax in Python. tifImage = rasterio.open(tif_file) dx = tifImage.transform[0] dy = tifImage....
Makarand's user avatar
1 vote
3 answers
212 views

Write three band RGB to file

I'm trying to create a 3 band RGB image from Sentinel 2 bands but I seem to be trying to write an array of inconsistent shape: For example: ValueError: Source shape (1, 10980, 10980, 3) is ...
BERA's user avatar
  • 71.4k
1 vote
0 answers
104 views

How to crop multiple polygons from raster as fast as possible?

I am trying to crop raster images using pre-defined geometries (vectors). I have images from PlanetLabs(daily) and regions of interest. Raster images vary, so they can contain only one area that ...
Miko's user avatar
  • 39
0 votes
1 answer
91 views

Setting null values of a raster to -1 or np.nan in numpy array when original raster has 0

I have a raster that has values 0, 1 and No-Data. I want to convert the raster into a numpy array with No-Data to -1 and not 0. with rasterio.open(y_path, mode="r+", nodata=None) as src: ...
Hrushi's user avatar
  • 169
0 votes
1 answer
22 views

Clipping a raster via mask on runtime before uploading into GeoServer

I have point data which is being interpolated and a raster is generated. The raster is a rectangular grid and I need the raster of Pakistan only. I'm using shapefile of Pakistan to specify the bounds ...
Hayat Ullah Abid's user avatar
3 votes
1 answer
218 views

Calculating difference between two raster layers in Python

I have two raster layers(same extent) that represent land cover classes. So, I want to extract only class 1 and calculate the difference between class 1. The expected output should be like the figure ...
Yasumin's user avatar
  • 133

1
2 3 4 5
17