New answers tagged rasterio
0
votes
Filling with values the area outside the cropped raster but still inside the masking polygon
I managed to solve the problem myself, so I am posting the code for others with the same problem.
I masked the raster with a polygon.
I then rasterised the masked polygon.
I performed a mosaic ...
0
votes
How do I open certain window from raster file
Just pass the raster dataset transform.
with rio.open(data.tiff) as data:
rst = data.read(1, window=from_bounds(
bounds['left'], bounds['bot'], bounds['right'], bounds['top'],
...
1
vote
Accepted
Xarray Dataset to raster - ValueError: failed to prevent overwriting existing key grid_mapping in attrs
See: https://corteva.github.io/rioxarray/stable/getting_started/getting_started.html
ds = xr.open_dataset("TerraClimate_tmin_1958.nc", decode_coords="all")
With decode_coords=&...
3
votes
Specifying target resolution when resampling with rasterio
You just need to figure out the scale factor from your chosen and current pixel size, e.g. I want to resample this 10m resolution "input.tif" to 12.5m:
import rasterio
from rasterio.enums ...
2
votes
Accepted
'Affine' object does not support item assignment (rasterio)
If you want to modify the raster, you either need to open in r+ mode or w mode depending on if you wish you create new raster or modify inplace
Using r+
ftdm = rasterio.open(dtm_path, 'r+')
ftdm....
1
vote
Accepted
Extract shapes and shape data from GeoTIFF using Rasterio and store as GeoJSON
shapes returns an iterable of tuples with geometry and value, you can use geopandas to parse the geometry into a valid geojson.
import geopandas as gpd
import rasterio
from rasterio import features
...
0
votes
How to solve rasterstats nodata warning
You may have set nodata on your raster, but you are not passing that raster to rasterstats.zonal_stats, you are passing a numpy array. And numpy arrays don't have a nodata property.
Just like you ...
0
votes
Finding latitude and longitude for pixel values
You could do something like the following which:
only reads the data into memory once and as required as it uses dataset.sample() instead of dataset.read() and generators instead of list ...
4
votes
Accepted
Changing band datatype to uint64 using rasterio
According to the rasterio source code for dtypes, valid dtypes does not include uint64. Instead use uint32
1
vote
Parallelizing mask process using geopandas to cookie cut a rasterio object
As an alternative to rolling your own parallel processing implementation, here's an simple example of using dask and dask-geopandas to parallelize some polygon on raster statistics using the ...
0
votes
Using rasterio to show RGB image with nodata
Note that show is a wrapper on imshow and you can pass imshow kwargs to it.
I believe imshow itself would handle a 4th band as an "alpha" (i.e. transparency) layer, but you can also provide ...
0
votes
Using Rasterio or GDAL to stack multiple bands without using subprocess commands
With gdal and numpy the following is possible assuming the images are the same size (rows and columns) and have the same CRS (e.g. 10m bands from a Sentinel 2 scene).
import gdal
import numpy as np
...
Top 50 recent answers are included
Related Tags
rasterio × 662python × 477
raster × 171
gdal × 165
geotiff-tiff × 74
coordinate-system × 60
geopandas × 58
numpy × 56
rioxarray × 35
qgis × 26
masking × 26
shapefile × 25
matplotlib × 22
shapely × 20
affine-transformation × 20
geojson × 19
clip × 19
fiona × 19
sentinel-2 × 17
xarray × 17
rasterization × 15
netcdf × 14
resampling × 14
rasterstats × 13
georeferencing × 12