Questions tagged [rasterio]

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

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

Stack two numpy array into one image with two bands in order to clip it with anotherr shapefile

I have two np array,'array 1' and 'array2' , and I have one image with 3 bands. I want to stack array 1 and array two to be one image with two bands with the same shape as my image and then to clip it ...
1
vote
0answers
16 views

Different values when i try to use a window in rasterio

I've been having a problem using windows in rasterio, probably a misunderstanding on my part. My goal is to dump a specific data from a band into a csv file, first I tried to use a window but the ...
0
votes
0answers
19 views

Change raster type gdal to raster type rasterio in Python

I have created raster using "rasterize" function with GDAL, Python My problem is that the result is type gdal <class 'osgeo.gdal.Dataset'> and I would like it to be rasterio, e.g: &...
2
votes
1answer
35 views

How can I render a composite (multi-band) raster in true color in QGIS?

I have gone through most QGIS troubleshooting steps in the GIS stack exchange but have not found a solution. I have imported a composite multi-band spectral GEOTIFF raster as part of the Hansen Global ...
1
vote
1answer
174 views

How to write BIGTIFF raster files with rasterio

A few months ago I had a hard time in finding a way to read BIGTIFF files. In the end I only managed to do so by creating a new conda environment with the following options: conda create -n env_name ...
0
votes
1answer
15 views

Apply Canny edge filter on raster failes with scikit-image

I have raster with one band and I would like to do edge detection with Canny edge filter. This is my raster: I have opened it with rasterio and covert it into array : img=srs.open("raster.tif&...
1
vote
0answers
20 views

Rasterio doesn't display the differnet bands of image

I have one raster which has three different bands. The two first bands look like this (in qgis): and the third band looks like this ( missing values in some places: The three bands sit on top of ...
0
votes
1answer
75 views

“Spatial join” between raster and shapefille- give raster the shapefile values with python

I have raster which has NDVI values .In addition, I have shapefile(geopandas) on top of this raster but it doesn't fully covers the raster (illustration): the shapefile has column which contain data ...
1
vote
0answers
27 views

Exporting GeoTIFF raster to GeoPandas dataframe

I'm just starting in the field of GIS (mostly worked with just python before) and got stuck on a problem. I'm looking for a way to polygonize an already masked GeoTIFF raster with population data in a ...
1
vote
0answers
17 views

How to plot raster data in leaflet

I'm trying to develop gis based web application. I'm using leaflet for frontend and django for backend. My requirement is to plot raster data in leaflet. I'm using rasterio for reading raster file. ...
1
vote
1answer
77 views

Crop/clip raster with shapefile that do not overlap

I have shapefile that intersects with a raster but do not fully overlap : I would like to clip the raster with this shapefile but every time I try I get this error message: ValueError: Input shapes ...
0
votes
0answers
13 views

Ignore raster no data

I'm clipping several rasters with different polygons and I've realized that some polygons fall on top of areas with no date values of the raster, returning me as a result completely empty clipps with ...
1
vote
2answers
318 views

Overlay two raster GeoTIFFs using rasterio mask

I'm trying to crop two different geotiffs/rasters using a polygon with rasterio's mask function in order to get two corresponding/overlapping cropped numpy arrays of the same size/shape. The problem ...
0
votes
0answers
37 views

NameError: name 'src' is not defined

I am trying to clip a raster using a geoJSON without writing to my disk. The following code compiles and produces the correct result. import tempfile import fiona import rasterio from rasterio.io ...
0
votes
0answers
27 views

Display raster with earthpy shows one color raster without values

I'm new to Earthpy, I am trying to display raster and on top of it I want to display polygon. The problem is that when I display the image it looks like blue rectangle and doesn't have different ...
1
vote
2answers
51 views

Can I open remote datasets with Rasterio?

I know I can open remote datasets with Gdal, I was wondering if I can do the same with Rasterio? Gdal bindings code of what I mean by opening remote dataset: import gdal import numpy import matplotlib....
1
vote
2answers
48 views

How can I merge two bands with different sizes using Rioxarray?

I have two images that I want to combine as follows Expected result: I tried to use the function rioxarray.merge.merge_arrays() in the following way but I got this error that I can't understand: >&...
4
votes
2answers
108 views

“Copy” Image coordinates to another image that is nd.array

I have image with three bands. I have script predicts the first band pixels values by using the two other bands and in the end generates an image.The generated image is at the beginning pandas table, ...
0
votes
0answers
20 views

Select only raster overlapping shape files using Rasterio

I'm cutting out several polygons from different rasters using the IDs of a shapefile and I would like the images to be just those polygons that overlap the raster without saving the empty images. ...
1
vote
0answers
17 views

Concatenating numpy arrays based on their relative positions as defined by associated Affine transforms

I have split a raster into 4 numpy arrays to feed into machine learning algorithms. I would now like to join to results of that process back into the full array. For each I have a numpy array, and an ...
1
vote
0answers
40 views

Plot polygon on rasterio window

I'm trying to plot several polygons on a raster. Several posts suggest to use matplotlib and descartes like this one: Plot shapefile on top of raster using plot and imshow from matplotlib My polygons ...
2
votes
2answers
2k views

rasterio mask method

I am using a simple ASCII raster file to test the rasterio.mask module ncols 4 nrows 4 xllcorner 0 yllcorner 0 cellsize 0.5 nodata_value -9999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 I generated the ...
3
votes
2answers
390 views

Reading a WMS/ raster map with rasterio

Can I read a raster map which has been constructed in mapserver as WMS with rasterio? I tried : from rasterio.io import MemoryFile def print_metadata(dataset): print(dataset.profile) url ='...
2
votes
0answers
19 views

Rasterio error too many point when reproject from epsg:4326 to Behrmann

I am trying to reproject a raster image with the raster package. The source CRS is EPSG:4326 and the destination CRS is Behrmann obtained from another raster, but I get an error. I leave you the code ...
0
votes
1answer
17 views

How to get pixel positions when cropping a raster with rasterio? (Faster)

I am trying to crop a raster but instead of just getting the values of the cropped raster I am trying to get the positions of that values on the matrix. I already did this with this code: import ...
2
votes
0answers
24 views

How to overlay and combine a choropleth and a shaded raster in Python?

I want to make a choropleth map of regions but shade it according to local population density. This is not the problem of masking a raster with a shapefile but to overlay two representations of data ...
1
vote
2answers
53 views

Rasterio merging went wrong

I try to merge some multiband rasterfiles (Sentinel 2 data) with Rasterio into a single rasterfile but the result is incorrect. The files are too big to fit in my RAM completely, but I have enough ...
1
vote
1answer
28 views

Rasterio creating composite/stack much larger than the individual bands

I am using rasterio to create a stack of eight bands and each individual band is about 1GB, but when it's stacking them the output (with a lzw compression) is a tif that's over 53GB! This seems huge ...
5
votes
3answers
4k 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 ...
3
votes
1answer
108 views

Calculate new band for satellite image after predict values with RF

I have satellite image which contains 3 different bands. I'm using Python (jupyter notebook) in order to calculate new band by applying random forest regression. My problem is that after I have ...
1
vote
0answers
15 views

Rasterio mask removes alpha band

I have a geotiff image that I am clipping to a geojson polygon using rasterio. When I load input the image in QGIS, it has an alpha band (4 bands total). rasterio says it only has 3 bands, which ...
0
votes
0answers
13 views

Displaying a multi-band raster using Rasterio and Matplotlib

I am attempting to visualize a raster a 4-band (RGB+NIR, stacked) Sentinel-2 raster using Rasterio and Matplotlib in Python, and getting an unusual image. Here is the code so far: import matplotlib....
2
votes
1answer
271 views

Updating a subset of raster values using open source Python?

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 ...
1
vote
2answers
1k views

Error reprojecting Landsat with rasterio

I am trying to reproject on python 2.7 a Landsat8 image from UTM 19N to UTM 18S using rasterio, reading the docs I found and example on the documentation and just change the input, output file and ...
3
votes
1answer
5k views

How to visualize multiband imagery using rasterio?

How do I plot a satellite image using rasterio? I'm able to plot the individual bands but not the entire image. Is there a way to combine the separate R, G, B numpy arrays to create a standard RGB ...
0
votes
2answers
822 views

Python - Mask raster array using shapefile or rasterio

I have a raster that I have resample using rasterio, where img.shape is (5490, 5490) if img.res[1] == 20: img = img.read( out_shape=(img.count, img.height * 2, img.width * 2), ...
1
vote
0answers
22 views

How to write multitime NetCDF raster with rasterio and netCDF4?

My code is: import numpy as np import rasterio from rasterio.warp import calculate_default_transform, reproject, Resampling from netCDF4 import Dataset mask=rasterio.open(path1) dst_crs='EPSG:4326' ...
1
vote
1answer
27 views

Should I rasterio.open the destination when reprojecting raster?

I use the code: import numpy as np import rasterio from rasterio.warp import calculate_default_transform, reproject, Resampling mask=rasterio.open(path1) dst_crs='EPSG:4326' with rasterio.open(path2)...
1
vote
1answer
116 views

How to determine which GDAL version rasterio uses?

I want to resample a georeferend raster .tif file with Python using rasterio. I found this: example and here is a description of the resampling methods I have to use the max method which is ...
0
votes
1answer
29 views

Extracting pixel values by overlaying polygons

I am trying to extract pixel values by overlaying polygons. I use a code after Patrick Grey (http://patrickgray.me/open-geo-tutorial/chapter_5_classification.html). When I masked the image with the ...
3
votes
0answers
33 views

Why do the rasterio Resampling methods ‘max’, ‘min’, ‘med’, ‘q1’, ‘q3’ give a segmentation fault?

I want to resample a georeferend raster .tif file with Python using rasterio. Here is the example I found example and the documentaion of the resampling methods. When I am using the following methods ...
0
votes
2answers
29 views

Mask raster with second, categorical raster in python

I have two rasters. One is a "normal" Sentinel-2 L1C and the other one is a categorical raster with levels from 0-5. They are both of the same extent. Is there any way to set pixels to NA that are of ...
1
vote
2answers
156 views

How to find the geographic coordinates of a pixels of known value in a set of images?

I am trying to know the geographic coordinates of pixels whose pixel value is known from its corresponding GeoTIFF image/array of interest. clip = [[[1.0 2.3 3.3 2.4 2.6 2.7 3.4 3....
0
votes
0answers
47 views

Interpolate nodata in rasters using Python

I have a raster of the shape (1000,1000) and some areas having no data values. I would like to fill the data gaps by interpolating or tinning (does not matter) over the surrounding areas, however I ...
5
votes
2answers
51 views

Create pandas df from raster image- each pixel is a row

I have raster image with 3 bands. I would like to convert this image to csv file wso each row will be pixels and each column will be one band, so I can see easily the three values each pixel got. ...
0
votes
0answers
19 views

Get pixel snapping using for variable feature extents (using GDAL/rasterio)

I would like to apply consistent pixel snapping/origin to multiple rasters of same CRS and resolution (pixel size), but different extents using GDAL and/or rasterio. In terms of functionality, I am ...
0
votes
0answers
170 views

Geopandas geodataframe copy with where clause causes geometry issues

Question up front: What is likely happening here, where when I take copy of the dataframe with a where clause present that there is an apparent break in the geometry, as implied by the linestring ...
0
votes
0answers
28 views

Creating Daily Mosaics from Orbiting Satellite Imagery

I'm trying to combine Sentinel-5p L2 Cloud Optimized Geotiffs (COGT) files into daily aggregates. In some literature these daily aggregates would be called "L3" data. Sentinel-5p captures 13-14 ...
0
votes
1answer
23 views

Systematic sample of a gdal raster and output to tif

I need to sample a raster from a geotif and output the result to a new tif file. This answer (from @snowman2) may have got me some of the way, but I'm still struggling. Here's a reproducible ...
2
votes
1answer
131 views

Using rasterio to show RGB image with nodata

This question is same as https://stackoverflow.com/questions/59132459/use-rasterio-show-rgb-image-with-nodata I have a multiband image with nodata value (which is Landsat and been set nodata to 0). ...

1
2 3 4 5
8