Clean and fast and geospatial raster I/O for Python programmers who use Numpy
Questions tagged [rasterio]
440 questions
0
votes
0 answers
'str' object has no attribute 'get' when creating a mask on dataset
i am trying to make a mask on a dataset as follows:
out_image, g= rasterio.mask.mask(dataset=NDVIsTIFFAsDataset, shapes=bufferedTreatmentAsGeoJSONInEPSG3857)
the value of the shapes parameter is shown below in the geojson-section.
when i run the…

Amrmsmb
- 1
- 27
- 104
- 226
0
votes
2 answers
How to resolve : "IndexError: band index 1 out of range (not in ())". Raster. Rasterio
I am trying to plot MODIS data product MOD09GQ. The following is my code and console output:
import rasterio
from rasterio.plot import show
import numpy as np
import matplotlib.pyplot as plt
filepath1 =…

Sayantan4796
- 169
- 1
- 10
0
votes
1 answer
Why do I get negative dimensions are not allowed merging rasterio datasets?
I am trying to use Python's rasterio library to analyze GIS wind data available here. I've written this reduced program:
import numpy as np
import rasterio as rio
from rasterio.merge import merge
file1 =…

mmachenry
- 1,773
- 3
- 22
- 38
0
votes
1 answer
Reprojection of North Polar Stereographic binary to Lon/Lat grid (rasterio or gdal in python)
Now, I am working on Stage IV dataset (Precipitation dataset in CONUS).
https://data.eol.ucar.edu/dataset/21.093
This is a binary data that shapes (1121 x 881) array and local 4km polar-stereographic grid.
The header files includes;
"polar stereo:…

TBan
- 1
0
votes
2 answers
rasterio.plot.show_hist - How to change / modify x_label, y_label?
By default, rasterio.plot.show_hist(...) sets the histogram title to "Histogram", x_label to "DN" (for Digital Number) and y_label to "Frequency". There is a parameter for the 'title' but nothing for x_label and y_label.
How to change it? For…

Claude COULOMBE
- 3,434
- 2
- 36
- 39
0
votes
0 answers
How to get Jupyter Notebook to link to another python installation?
I am trying to use a specific package called rasterio in python which I have been unable to use. What I am specifically confused about is the disconnect I am seeing between Windows Command Prompt, Anaconda Prompt, and Jupyter Notebook, the platform…

LostinSpatialAnalysis
- 565
- 5
- 22
0
votes
2 answers
GeoDataFrame is Inverted when I converted from Raster to Vector using RasterIO
I'm currently using this code to convert a raster file to a geodataframe:
import rasterio
from rasterio.features import shapes
mask = None
with rasterio.open(#INSERT TIF FILE HERE) as src:
image = src.read(1) # first band, not sure yet how to…

Oshean Lee Garonita
- 33
- 1
- 5
0
votes
1 answer
Python Zonal statistics script: Problem after trying to install rioxarray
I have a script that used to work for calculating zonal statistics (median), but now I get the AttributeError: 'DatasetReader' object has no attribute 'affine'.
Here is my code:
with rasterio.open(f'{project_data}/ras.tif') as raster:
array =…

Carina
- 39
- 5
0
votes
1 answer
Tiff images to numpy arrays
import rasterio as rio
from rasterio.plot import show
from sklearn import cluster
import matplotlib.pyplot as plt
import numpy as np
import glob
for filepath in glob.iglob('./dengue3/*.tiff'):
elhas_raster = rio.open(filepath)
elhas_arr =…
user15653028
0
votes
1 answer
Reproject coordinates with rasterio creates a irregular grid from an regular grid
I have geotiff files load into xarray with a crs = EPSG:31467. I want to transform/reproject (don't know if there is a difference) these files into EPSG:4326. To do that, I use rasterio.warp.transform function which needs 1D arrays for x,y. To…

till Kadabra
- 478
- 9
- 21
0
votes
1 answer
Copy raster exif in GDAL
I have two images with the same size - first one is an image from a drone and the second - a mask. I need to subtract both images and of course translate the exif data from the original image into the resulting one. Is it possible in gdal or…

Aceituna
- 1
0
votes
1 answer
Rasterio Creating TIFF file
I tried to use the code on the Rasterio-doc website to write an array as a TIFF to disk
https://rasterio.readthedocs.io/en/latest/topics/writing.html
with rasterio.Env():
profile = src.profile
profile.update(
dtype=rasterio.uint8,
…

The_perks_of_being_on_mars
- 81
- 1
- 6
0
votes
1 answer
Wrong raster format when multiplying rasters using rioxarray
I'm trying to add two rasters created using the rioxarray package. Both have the same xy resolution/grid (3905y, 13566x), but when added together suddenly the grid structure changes (1629y, 6799x). How to add two rioxarray rasters while keeping the…

CrossLord
- 574
- 4
- 20
0
votes
1 answer
Python unifiy two geosystems
I am trying to unify the geosystem of a shp file and a DEM file. I tried to use rasterstats.zonal_stats to find the overlap between these two data but it returns None. So I assume there is some problem with the geo system.
I printed the shp file crs…

Xudong
- 441
- 5
- 16
0
votes
1 answer
How to convert Zarr data to GeoTiff?
I want to load the HRRR forecast data into Google Earth Engine, so I think I need to convert it to GeoTiff.
e.g.
import xarray as xr
import s3fs
fs = s3fs.S3FileSystem(anon=True)
urls =…

Adair
- 1,697
- 18
- 22