Skip to main content

Questions tagged [rasterio]

open source Python library for reading and writing geospatial raster data

Filter by
Sorted by
Tagged with
1 vote
0 answers
31 views

cellSize calculation in Python

To create a raster file of cell size, which is similar to the function of cellSize function in terra library in R. It takes input raster with whatever the input's projection, and calculate cellsize in ...
Sang Truong's user avatar
0 votes
0 answers
18 views

WGS84 elevation from ALOS 30m DSM tif's using rasterio

I am new to GIS processing. I am trying to compute WGS84 elevation for given latitude and longitude using the JAXA ALOS 30m DSM. I use rasterio and code from a minimal example I found that looks like ...
Francesco Callari's user avatar
1 vote
1 answer
43 views

How to plot single land use / land cover classes on a map in python

I want to analyze Corine Land Cover data. It is raster data in a .tif file. Currently, I am using rasterio to handle the raster data. Question: How can I plot only a single land use on a map? My goal ...
tofri's user avatar
  • 13
0 votes
0 answers
30 views

How to deduce zoom level from gsd?

I have the following code: with rasterio.open(image) as dataset: transform = dataset.transform sizeX = transform[0] I need to deduce the maximum zoom level for which it makes sense to tile an ...
tlzg's user avatar
  • 161
0 votes
0 answers
24 views

Sample Raster Value code check

I have written code to loop through prism climate data (rasters) data at certain 2-week intervals then take the mean of that interval then append it to the original shapefile. #%% Processing Sinks for ...
Ekkehardt Rosasee's user avatar
2 votes
1 answer
62 views

Calculating NDVI from Landsat data

I have multiple folders containing landsat data from different years . I have been just testing Landsat 5 before doing them all but I feel as though something is wrong with the code. def ...
Ekkehardt Rosasee's user avatar
1 vote
1 answer
31 views

Opening rasterio datasets in threads

I have an application that requires opening a lot of GeoTIFFs, and I would like to do it concurrently. Basically, I am calling rasterio.open() in each thread and storing the resulting DatasetReader ...
eba's user avatar
  • 13
0 votes
0 answers
28 views

Colouring MapInfo polygons from Python

I'm using rasterio and geopandas to generate MapInfo TAB files. The resulting file contains a lot of polygons (~10 000). Here is the function I use: with rasterio.Env(): with rasterio.open(...
Riuss's user avatar
  • 1
0 votes
0 answers
33 views

Compressing GeoTiff with Rasterio

I am trying to process several GeoTiffs from Landsat satellite. I wrote a function for clipping and then wanted to use compression on the output bands. However I try it, the compression is just not ...
Tereza Pohanková's user avatar
0 votes
0 answers
29 views

Error: Number of pixels in mask does not match predictions size in Python/Rasterio workflow

I have implemented a random forest model using scikit-learn and Rasterio in Python to predict pixel values within a shapefile containing multiple polygons. However, I'm encountering an error:...
user30985's user avatar
  • 357
0 votes
0 answers
41 views

How to clip a raster file using a GeoJSON?

I am trying to clip or crop out the area of interest from a multi-spectral tiff file downloaded from Sentinel-2, using Rasterio and GeoPandas. For reference here are the code snippets - import ...
Anurag-Sharma's user avatar
2 votes
1 answer
56 views

Mapping spatial corrdinates (X,Y) back to pixel space using Rasterio

For the problem I am solving I have lat/lon values in DataFrame and need to check if these values coincide with some of the satellite images I have. This part I managed to solve following this post (...
user144483's user avatar
1 vote
1 answer
119 views

Fastest way to clip millions of small polygons and storing results as JSON [closed]

I have a dataset with couple million farm polygons (around 2.5 million and only expected to grow in the future), and I need to calculate the NDVI for these farm polygons, with some basic stats (...
Hasan Mustafa's user avatar
1 vote
0 answers
79 views

Using dask.distributed with rioxarray rio.to_raster results in `ValueError: Lock is not yet acquired` [closed]

I am trying to write some code using dask.distributed.Client and rioxarray to_raster that: Concatenates two rasters (dask arrays) Applies a function across all blocks in the concatenated array Writes ...
katieb1's user avatar
  • 31
0 votes
2 answers
55 views

Averaging two rasters preserving the non-overlapping areas with python gdal

I have two rasters with the same projection that partially overlap. How to to calculate the average of the overlapping area preserving the values from one of the rasters in non overlapping areas using ...
ilFonta's user avatar
  • 1,057
0 votes
1 answer
35 views

Removing 'bad bands' from hyperspectral data in GDAL

I'm new to using GDAL and need to process hyperspectral data. I'm trying to get rid of bands within atmospheric absorption windows, but I'm note sure how to do that in GDAL or other python tools. My ...
monicaJ's user avatar
1 vote
0 answers
42 views

Passing affine transform to rasterio.features.rasterize() [closed]

I have generated a raster using code like the following: minx, miny, maxx, maxy = l1.bounds dx = (maxx - minx) dy = (maxy - miny) buildings_raster = rasterio.features.rasterize([l1], ...
Don Mclachlan's user avatar
0 votes
0 answers
35 views

Specify GDAL WarpOption align=False in rasterio function

After many hours of troubleshooting and scouring forums, I was able to solve a problem I was having: after using rasterio to clip one raster to the size of another, the shapes were slightly off so I ...
Samuel T's user avatar
1 vote
1 answer
67 views

rio.to_raster returns ValueError: cannot convert float NaN to integer

Maybe this is more like a Pandas question but when I try to write an xarray to a raster using rio.to_raster() I get a ValueError in Python. If I don't convert the type of xarray to int16 (this is a ...
Andrei Niță's user avatar
2 votes
3 answers
84 views

Convert Raster to CSV and plot as points on the grid using Python

I'm trying to convert raster to CSV file with coordinates and plot them and encounter a problem. I have a raster .tif file with some buildings in Denmark projected in EPSG:7416 CRS. I read .tif file ...
errenmike1806's user avatar
1 vote
1 answer
127 views

User-defined reprojection using rioxarray

I'm trying to reproject a raster dataset using a user-defined projection in Python. I was able to achieve the desired reprojection setting ArcGIS's arcpy.CreateCustomGeoTransformation_management tool ...
Liyuneh's user avatar
  • 11
0 votes
0 answers
30 views

Aligning two rasters using rasterio.reproject

I collected a set of images using a drone. After that, I created a set of orthomosaic images. Next, I took two images that were acquired for the same location and at different times of the year. I am ...
Sergey Malashenko's user avatar
0 votes
0 answers
31 views

Reprojection of a raster window in rasterio

I'm working with the ETOPO global relief model, trying to take samples centred at different longitudes and latitudes and reproject them into a locally flat coordinate system. I'm trying to do this by ...
pt3's user avatar
  • 101
1 vote
0 answers
20 views

rasterio._err.CPLE_OutOfMemoryError: /io/gdal-3.6.4/frmts/mem/memdataset.cpp when trying to create a new large rasterfile

I am trying to step by step save a lot of data in a single GeoTiff file but rasterio seems to fail right away when I try to open the file I want to write my data to due to my available RAM not being ...
Sven's user avatar
  • 11
0 votes
0 answers
16 views

Unexpected result with all_touched in geocube

I am using the geocube.api.core.make_cube function as a way to build a template array for fast data extraction in my pipeline. Basically, I will use this template array to store the row-index of a gpd....
topcat's user avatar
  • 327
1 vote
1 answer
91 views

Reproject large raster using Python

I have some large rasters that I want to reproject in a memory-safe way, using a second raster as a template . This code works nicely for smaller ones, but when they are large the Python kernel ...
TheRealJimShady's user avatar
0 votes
1 answer
15 views

Using spatial resolution in RCM

I have some RCM data acquired at 3 meter resolution mode. This means that the range resolution is 3 meter and azimuth resolution is 1 meter. The resolution can be confirmed by the following link. ...
Sparsh Garg's user avatar
0 votes
0 answers
95 views

How to merge several Sentinel-2 images using the median for the overlapping areas?

I'm having a little bit of trouble coming with the best way to do this. I have several rasters that contain each 12 Sentinel-2 bands, not all from the same tile that I want to do some preprocessing ...
rrwork___'s user avatar
0 votes
0 answers
76 views

rioxarray.open_rasterio() won't close a file when using it with a context manager

I am writing some unit tests to test reading in raster data into an xr.Dataset data structure via the rioxarray.open_rasterio() method. The code creates a test raster to read into rioxarray....
Adriano Matos's user avatar
0 votes
1 answer
35 views

Windowed writing with rasterio produces zeroed output

I am trying to create a large raster of 64-bit integers from the metadata of another file. This is done row by row, writing the output with the rasterio Window class. Below is a very simplified ...
Luís de Sousa's user avatar
1 vote
0 answers
26 views

Python - Removing percentage of forest cover (pixels) of a raster based the percentage of forest loss of a gdf's column

I have a Boolean raster that shows forest cover as 1 and no-forest as 0. The spatial resolution is 500m. My gdf brings the municipalities boundaries and one of the columns is the percentage of forest ...
Rodrigo Moreira's user avatar
0 votes
1 answer
107 views

How to read a MemoryFile with rasterio

I'm working with images from different sources in python and even though they have the same pixel size and are clipped to the same rectangle, their shapes don't match (probably because of issues ...
stray_dog's user avatar
0 votes
0 answers
68 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
165 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
57 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
99 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
1 answer
74 views

Rasterio convert vertical datum of NAVD88 to WGS 84

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 WGS 84. To do the ...
Szymson's user avatar
  • 21
1 vote
1 answer
131 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
2 answers
141 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
51 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
108 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
2 votes
2 answers
102 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
133 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
91 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,719
1 vote
2 answers
116 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
67 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
37 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
114 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
109 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
397 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
  • 121

1
2 3 4 5
17