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
0answers
14 views

Unpack error occuring when sampling raster values to points with rasterio

I'm new to Python. I'm trying to sample raster values to points based on the geometries of a shapefile using the below code but I'm receiving the below error . import fiona import rasterio as rio ...
1
vote
0answers
29 views

Reading in GeoTIFF with different CRS and Transform with rasterio

I have multiple TIF files with different resolutions that I want to combine using rasterio. I am using a modification of the example given in the documentation here. However, on closer inspection ...
2
votes
0answers
41 views

Converting tile image into raster using rasterio

I want to convert a tile image (.tif) into a raster data (.tif) and assign lon/lat to the data. (I know how to get the lon/lat of a tile.) The problem is I don't know how to assign lon/lat to a raster ...
0
votes
2answers
28 views

How to convert shapely geometry linestring into shapefile?

I have extracted linestring from Landsat images. now, I am literally stuck what to do? I want to convert it into shapefile. It is actually coastline geometry. **In[1]:** type(water_lines_smooth) ...
0
votes
0answers
27 views

`Rasterio` and `CRSError: The EPSG code is unknown. Unable to open EPSG support file gcs.csv.` error

This seems to be an error that pops up for a lot of people from time to time. There are a number of posts on Github and other stackexchanges. I was not sure if there was finally any resolution to this ...
0
votes
0answers
18 views

How to convert 0 values to NaN values with rasterio

I clipped my tif image to smaller tif via using a shapefile as mask with rasterio python library. After that my square shaped clip has bigger extent than shapefile and outside the the shp area is ...
1
vote
1answer
179 views

Read and then write rasterio GeoTIFF file without loading all data into memory

I work with large drone image raster files, on the order of 40,000 x 40,000 and above. I have a large uncompressed GeoTIFF file and I want to use rasterio to rewrite the file in compressed format. I ...
0
votes
0answers
13 views

rasterio opens file from AWS S3 bucket on local machine, but can't find file when deployed to Google App Engine

I'm trying to run a python Flask app from the Google App Engine, that opens a file hosted on an S3 bucket and analyzes the data. When I deploy the Flask app on my local host, it runs like expected. ...
0
votes
1answer
26 views

An error occurred while writing a dirty block from GDALRasterBand::IRasterIO

I get the following error when trying to run rio-terrain on a GeoTIFF file : $ rio aspect input.TIF output.TIF Running aspect on sequential raster blocks Blocks done: [################################...
0
votes
1answer
35 views

Custom Colormap (cmap) rasterio, Python

I wish to display custom colours for the pixel values in my raster. How can I create a custom colormap (cmap)? In the example below, I have specified "magma" as the colour map. However, I ...
1
vote
1answer
43 views

Rasterio Window on Resampling open

Rasterio supports processing using window in order to avoid loading the entire image (as can be seen here). It also supports resampling images when using read (as can be seen here). However, I am ...
1
vote
1answer
46 views

Display GeoTIFF single band image in Python

I have a single band GeoTIFF image which displays correctly in QGIS. However I tried viewing the same file using matplotlib and rasterio but I get a different output. Is there something that I am ...
4
votes
2answers
103 views

How to choose cell assignment method in GDAL/rasterio rasterize functions?

I have a big (2GB) landcover shapefile I want to convert to a GeoTIFF file. For this purpose, I am using the gdal.Rasterize() function with the following options: rasterize_options = gdal....
0
votes
1answer
55 views

Using rasterio to crop image using pixel coordinates instead of geographic coordinates

I'm trying to extract a series of random patches of image from a larger satellite image (from worldview3). I want to extract patches of uniform size (say 512x512 for example). If it were a normal ...
1
vote
1answer
44 views

Splitting a GeoTIFF raster file into tiles in meters

I am new to GIS in general and I have started working with GDAL and Rasterio. What I am looking for is a method in GDAL or Rasterio that mimics the ArcGIS's SplitRaster function when the parameter ...
1
vote
1answer
45 views

How to reproject point if I only have the source TIFF extent

I made a point shapefile (using PySHP in Python) that represent objects detected through AI. This shapefile has no CRS and each point is X,Y relative to the image it was processed from (actually a ...
2
votes
1answer
49 views

Downsides to saving rasters with NaN as no data values?

I am working with a bunch of satellites images downloaded from Google Earth Engine as .tifs. I have masked some of the pixels in Earth Engine with values of -999999 where there are clouds. Everytime I ...
0
votes
0answers
18 views

Created GeoTIFF only has NaN values in PostgresSQL

I created a GeoTIFF file from a numpy array, loaded it into a PostgreSQL DB and now I want to retrieve this raster data and convert it back into a numpy array. I know this seems nothing really ...
1
vote
1answer
67 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 ...
2
votes
0answers
18 views

Different values when trying to use window in rasterio

I've been having a problem using windows in rasterio, which is 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 ...
0
votes
0answers
22 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
40 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 ...
0
votes
1answer
18 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
22 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 ...
1
vote
0answers
78 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
27 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. ...
0
votes
1answer
91 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 ...
0
votes
0answers
16 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
1answer
61 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 ...
1
vote
1answer
90 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
33 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
54 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
55 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: >&...
0
votes
0answers
24 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 ...
4
votes
2answers
119 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, ...
2
votes
0answers
21 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 ...
2
votes
0answers
25 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
0answers
63 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 ...
1
vote
1answer
32 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 ...
1
vote
0answers
19 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
14 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....
3
votes
1answer
111 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 ...
0
votes
1answer
23 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 ...
1
vote
0answers
32 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
31 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)...
3
votes
0answers
41 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 ...
1
vote
1answer
136 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
2answers
32 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 ...
0
votes
0answers
66 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 ...

1
2 3 4 5
8