Questions tagged [rasterio]

open source Python library for reading and writing geospatial raster data

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

Calculation of the greatest fall in the river

I have a task to write a python program using the 'gdal', 'geopandas', 'reasterio' and 'fiona' libraries. This program is to calculate the greatest fall in the river (height difference between the ...
user avatar
  • 11
0 votes
1 answer
21 views

Plotting Raster Above a shapefile

I'm trying to plot a raster above a shapefile in python. My code is working however I can't seem to get the raster to plot above the shapefiles. It only appears when I don't show countries, rivers ...
user avatar
2 votes
1 answer
12 views

Calculate height profile from cogeoTiff using rasterio

I want to create a service calculating height profiles using our CoGeoTiff LaserScan data from Austria. It has a 1m resolution at its deepest level and is about 400GB big. Generating height profiles ...
user avatar
0 votes
0 answers
3 views

rasterio: Ralign clipped raster with base x and y axes

I am clipping a raster with a polygon imported from a shape file and want to realign the clipped raster, such that the output image does not have any zero valued edges. Similar to https://rasterio....
user avatar
  • 1
0 votes
0 answers
31 views

Python Intersect Vectorize a raster containing holes

I want to vectorize raster that contains holes (nodata) in the areas with valid data. My current version uses rasterio.features.shapes: shape_list = list(shapes(raster.values, mask=raster.values !=...
user avatar
0 votes
0 answers
25 views

Discrepancy in output volume calculation for same rasters in QGIS and Rasterio

I have been comparing my volume calculation results on the same rasters with QGIS Raster Surface Volume tool and the following python script: import rasterio import numpy as np filename = 'D:/raster....
user avatar
0 votes
0 answers
18 views

Rasterio error RuntimeWarning: overflow encountered in reduce return

I have extracted a mask from a raster in order to test out multiple volume calculations between QGIS and Python I'm using rasterio to read in the tiff image and calculate its volume: import rasterio ...
user avatar
0 votes
1 answer
36 views

Why do rioxarray reprojection and pyproj transform give different values when selecting a pixel by point coordinates?

I'm opening this grib file using rioxarray and reprojecting to WGS84 in the following manner with the goal of grabbing pixel values by coordinates. import rioxarray url = 'https://noaa-hrrr-bdp-pds....
user avatar
  • 448
0 votes
0 answers
20 views

Mask non value flags when opening dataset with rioxarray

I'm trying to read Leaf Area Index (LAI) data from the MODIS product (MOD15A2) using rioxarray, but there are a number of land cover flags (e.g. 253 = land cover assigned as barren) that don't get ...
user avatar
  • 1
0 votes
0 answers
16 views

How to stack multiple bands from many dates in Python?

I have this folders: and inside them there are sentinel2's raster bands. I'd like to stack them and return the stacked tiff to its folder. How do I do that?
user avatar
1 vote
0 answers
29 views

rasterio mask fill nodata with np.nan: TypeError: Cannot convert fill_value nan to dtype uint8

I'm facing troubles while reading a raster dataset having uint8 value when trying to fill the nodata gaps with np.nan. The following function works like a charm for opening a GeoTIFF DEM (having ...
user avatar
  • 6,698
0 votes
0 answers
29 views

GeoPandas & Rasterio - Overlaying rasters above a shapefile

I'm new to GeoPandas/Rasterio and I'm trying to make a piece of code for generating a map - I want to show a basemap shapefile (PAA.shp) and layer a raster on top (landuse.tif). Landuse.tif has 3 ...
user avatar
0 votes
1 answer
19 views

"GDALWarpOptions.Validate(): hSrcDS is not set" when reading a VRT pointing to a STACTA

Using rasterio.open() I was trying to read a VRT. This VRT pointed to another VRT and this in turn pointed to a STACTA file. This error message appeared: rasterio.errors.RasterioIOError: Read or write ...
user avatar
0 votes
0 answers
22 views

with rasterio.open gives IndexError: tuple index out of range

Description: This code is written in jupyter notebook using python for reading nitrogen values from OMI satellite files I am using Anaconda for running this notebook. here the code line with rasterio....
user avatar
  • 1
0 votes
1 answer
41 views

Inconsistent results between gdalWarp (with cutline) and rasterio.mask

Cropping with GDAL cutline vs Rasterio.mask with crop=True results in arrays with different sizes (by one row). I've tested the different Rasterio options but no luck. I'm hoping to match the GDAL ...
user avatar
  • 399
0 votes
0 answers
17 views

How to limit the increase in the output raster size during a raster operation in Rasterio?

Context: I'm subtracting two rasters and saving the result to my disk using Rasterio. I observed a significant increase (20x) in the size of the output file after the raster operation. # Reading the ...
user avatar
  • 375
1 vote
1 answer
64 views

Extracting raster outline to a vector geometry

I have a raster data set with an irregular outline (every value outside is NaN) in Python (loaded from rasterio v.1.3a3 ): I'd like to extract its outline to a vector shape (red in the figure below) ...
user avatar
  • 6,698
0 votes
1 answer
89 views

Rasterio to convert a GeoTIFF into a GeoJSON in Python [closed]

I am currently working in Python and would like to convert a raster GeoTIFF into a GeoJSON. (I am currently working with Jupiter notebook and ipyleaflet - they only display data as a GeoJSON and not ...
user avatar
  • 173
0 votes
0 answers
18 views

Projection error of EuroSAT (Sentinel-2) GeoTIFF

I am trying to plot the geospatial positions of multi-spectral satellite images from the EuroSAT dataset. While plotting all positions at once, I have come to the conclusion that I have some ...
user avatar
  • 101
1 vote
1 answer
74 views

Python cropping a TIFF with shapefile shifts the output slightly to the East

I have a shapefile that I use to crop GeoTIFFs. However everytime I use my code to do that, it slightly shifts my entire cropped TIFF to the East and I have no idea why. The pictures below show how ...
user avatar
  • 113
0 votes
0 answers
18 views

Can Rasterio python package read/open rasters stored in a Geopackage? [duplicate]

I've searched a lot and I couldn't find any code sample using rasterio to open rasters stored in a Geopackage. If someone knows anything about this topic, I would be greateful if the knowledge could ...
user avatar
1 vote
1 answer
62 views

How can I read a raster in a Geopackage with python?

I'm having a hard time trying to read (with python) a raster that I've saved in a Geopackage. I thought there would be a simple like rasterData = rasterio.open(gpkgPath, layer='DEM'), but when I run ...
user avatar
1 vote
0 answers
41 views

How to solve rasterstats nodata warning

I am using the zonal_stats function in the rasterstats package to calculate summary statistics from GeoTiffs containing vegetative index values. The summary statistics come out fine, however with each ...
user avatar
  • 61
0 votes
0 answers
47 views

Retaining NaN values in rasterio read

I am attempting to import a GeoTiff mask in which pixels of interest have the value 1, and off-target pixels are Nan using Rasterio. When viewed in QGIS and with plt.show(), off target pixels are ...
user avatar
  • 61
2 votes
0 answers
30 views

Can GDAL read/write Geopackage on RAM instead of disk?

I am working on a Python project that makes extensive use of GDAL's Geopackage vector and raster drivers. Since geopackage is essentially SQLite, I also use the Python SQLite library to do lots of ...
user avatar
0 votes
0 answers
24 views

Python Rasterio Writes JP2 without Colors

When opening a JP2 image in rasterio, the image seems to have the width and height dimensions flipped. So, I correct by changing the transform and Affine manually: src = rasterio.open("img.JP2&...
user avatar
1 vote
0 answers
22 views

Extract class from lat&lon GeoTIFF using rasterio [duplicate]

I would like to extract the coverland class from all available coordinates from a GeoTIFF downloaded from ESA website. I can get a JSON structure with the polygon coordinates. This is the code: import ...
user avatar
  • 35
1 vote
1 answer
57 views

Rasterization of polygon with area variable

The usual approach for rasterizing polygons/vectors is to take the values of polygons inside a grid cell and combine them somehow. This works well for field attributes that are not proportional to the ...
user avatar
0 votes
0 answers
55 views

Rasterstats not working on raster

I am trying to analyze a GeoTiff file with some geojson regions and rasterstats. But rasterstats doesn't seem to work. I suspect that is something related with the GeoTiff file, since I am using a new ...
user avatar
0 votes
0 answers
19 views

Cropping aviris image by shapefile of different projection

I am trying to crop an aviris image (ang20170925t192719_rdn_v2p10) that is in projection espg:32610 to keep pixels only intersecting a I15 crop shapefile that is in projection espg: 4269.I reproject ...
user avatar
1 vote
0 answers
25 views

Converting np.nan pixels to transparent with GDAL

I am attempting to create a mask layer of vegetation from aerial imagery of the soybean fields I work with. The code I am using is below. I am attempting to export the mask layer (exgMask) as a ...
user avatar
  • 61
1 vote
0 answers
21 views

Calculate statistics for multi bands

I would like to compute statistics for a multiband raster. How can I process? This is my code: python if os.path.isfile(_tmp_path_raster): dataset_raster = gdal.Open(_tmp_path_raster, ...
user avatar
1 vote
0 answers
15 views

Copy and paste style of a raster in rasterio or Gdal

Is there any way to copy the styles of a raster and paste it in another raster using rasterio or Gdal. I saw a question and the answer I found there was in pyqgis but I am using spyder to run my ...
user avatar
  • 165
0 votes
1 answer
64 views

Change raster `nodata` to nan on python

I've been trying to use rasterio.merge.merge() but it seems I have a nodata issue forbidding it (Rasterio.merge.merge() does not work): there is no value defined as nodata for my rasters (they all ...
user avatar
  • 107
1 vote
0 answers
25 views

Rasterio.merge.merge() does not work

I have 2 .tif files that I would like to merge with rasterio. They have the same crs, are in the same area, and overlap a bit. I tried to use the merge() function of rasterio.merge but I end up with ...
user avatar
  • 107
1 vote
2 answers
136 views

Extract selected pixel values with their coordinates

My goal is to get the coordinates of all pixels with a specified value (ex: maximum and minimum pixel values). # imports import numpy as np import pandas as pd import geopandas as gpd import rasterio ...
user avatar
  • 153
1 vote
1 answer
26 views

Overlaying raster and points to identify pixels

I have two elements - geo_df - a set of Points identifying different assets and a raster (grid) where each grid/pixel has an associated value. How do I overlay the points from the dataset upon the ...
user avatar
2 votes
0 answers
45 views

MODIS MCD18A2 (PAR) reproject via rasterio vs. via HDF-EOS

I downloaded MODIS L3 PAR data (https://lpdaac.usgs.gov/documents/750/MCD18_User_Guide_V61.pdf, https://e4ftl01.cr.usgs.gov//DP128/MOTA/MCD18A2.061/2014.07.04/MCD18A2.A2014185.h18v04.061.2021258072101....
user avatar
1 vote
2 answers
224 views

Find pixel value from GeoTIFF using latitude and longitude

I know very little of geospatial data. I have a GeoTIFF with a single band that contains a value per pixel (values go from 1 to 6). Using latitude and longitude, I would like to find (i) the ...
user avatar
2 votes
1 answer
245 views

Getting Rasterio transform/affine from lat and long array

I have lat, long, and data arrays data = np.array [[1,3],[2,3],[3,4]] lat = np.array [[44,43],[46,44],[43,45]] long = np.array [[33,32],[31,33],[36,33]] The coordinates here are random but my ...
user avatar
0 votes
1 answer
103 views

Calculate cell/pixel area with Rasterio in Python

The Situation I have a tile spanning 10° north-south (n-s) and 10° east-west (e-w), e.g. from 10-20W and 10-20N. This tile contains multiple pixels, e.g. with a resolution of n-s and e-w of 100m at ...
user avatar
  • 45
1 vote
0 answers
20 views

How to get the transformation for a georeferenced dataset in azimuthal equidistant projection using rasterio

I have a squared Numpy array with data. I also have both squared arrays of the same shape with lat and lon. I also know the projection used by this data, an azimuthal equidistant with known center ...
user avatar
  • 317
0 votes
1 answer
42 views

Pixel values changing when opening and re-saving file with rasterio

I'm using rasterio to analyze satellite imagery stored in JPEG2000 format and am having the problem that pixel values change when opening and then saving the same file again. Any ideas why this ...
user avatar
3 votes
1 answer
137 views

Subtracting raster from number using Rasterio

How can I subtract a raster from a constant value using Rasterio? I see many posts on how to subtract two rasters but not on subtracting a raster from a constant value. What I have tried: import ...
user avatar
  • 375
2 votes
0 answers
50 views

What are the advantages and disadvantages of reprojecting a raster?

When I reproject a raster with any software like QGIS, rioxarray, etc. Can it generate problems or loss of information in the pixels? For example: If I want to reproject a raster from UTM coordinates ...
user avatar
4 votes
3 answers
283 views

How to write a georeferenced GeoTIFF from known coordinates with Python rasterio

I have three numpy arrays, one with data, and two more with explicit longitudes and latitudes. I'd like to write this data to make a GeoTIFF file with rasterio such that I can load it with QGIS. The ...
user avatar
  • 317
0 votes
2 answers
114 views

Extract values from multiple rasters to CSV using Python

I want to use an old sofware to analyse my data with a new angle. This software is not compatible with the .tif format so I need to transform all my data into a .csv. The expected .csv structure is ...
user avatar
0 votes
0 answers
50 views

Dividing reflectance values of Sentinel-2 sets of bands using rasterio

I need to divide the reflectance values of a Sentinel-2 sets of bands. To do this, I have to divide each band by 10000 when I read in the band to write the stack. I have an example of my code snippet ...
user avatar
  • 1
1 vote
1 answer
112 views

Customize axis and labels of rasterio plots

I have three plots consisting in a vector polygon over three different raster layers arranged in facets. I used rasterio, geopandas and matplotlib. I would modify the labels of axis in order to show ...
user avatar
  • 1,007
0 votes
0 answers
42 views

Sentinel2 pixel values and grayscales in QGIS

My goal is to get the Sentinel-2 pixel values and coordinates. So I used python rioxarray_open.rasterio to load the Sentinel2 pixels values and plot the results in QGIS. pixel_value = rioxarray....
user avatar

1
2 3 4 5
14