All Questions
29 questions
1
vote
1
answer
405
views
Masking in rasterio changes the values the output file
I am masking a raster file using rasterio. I am doing this using the mask function. The result of the masking changes the value of the pixels when loaded to GIS.
import fiona
import rasterio
import ...
0
votes
2
answers
456
views
rasterio.fill.fillnodata doesn't work as expected
I have a DEM of a lake bottom, that contains a few holes (nodata) which I'd like to fill. For that purpose i'm using rasterio's fillnodata with a mask. Unfortunatly, I don't get the results I am ...
1
vote
1
answer
3k
views
Clip a GeoTIFF based on a bounding box coordinates using rasterio
I would like to clip a geodaframe based on coordinates. Let's say that I have the following bounding box from a GeoPandas dataframe. The projection is mollweide.
gdf.boundary.plot()
gdf.total_bounds
...
0
votes
1
answer
449
views
Output raster of rasterio.mask doesn't match CRS of input [closed]
I'm trying to mask a raster with population data with my area of interest. I reprojected the original population raster according to the AOI's crs, but after masking and writing the new file, the crs ...
4
votes
0
answers
292
views
Merge rasters and clip by a shapefile
I was wondering how to merge multiple TIFF files together and clip the mosaic by the bounds of a intersecting shapefile. I've been able to merge them and output as a .tiff, but am not sure how to to ...
2
votes
1
answer
208
views
Rasterio mask washing out result
Using the rio.mask.mask function to clip out a section of an ortho. The result .tif looks like it has been "washed" out. The pixel values from the ortho and the result are exactly the same, ...
2
votes
3
answers
11k
views
Masking with rasterio in Python
Introduction
I have a shapefile for my area of interest (which in this case is Tehran) and also a TIF file that contains the categorical information(cloud status). In this case, I want to mask the TIF ...
2
votes
1
answer
4k
views
Rasterio mask doesn't work with shapely polygon
I have raster which I want to mask with shapely polygon.According the rasterio documentation, rasterio.mask can work with shapely geometry.However, in this case, it doesn't work.
whenever I use my ...
1
vote
0
answers
753
views
Using a shapefile as mask with rasterio mask gives different affine transforms with rasters of the same projection and resolution
I have a list of n file paths to geotiffs of the same resolution and projection but with varying extents. In brief the goal is to
use Rasterio's mask module to use a shapefile containing a single ...
4
votes
0
answers
283
views
Inconsistently getting "Input shapes do not overlap raster", CRS appear to match
Masking topographic raster data by a shapefile (bedrock geology polygon).
Following this guide I do this:
with fiona.open("geology.shp", "r") as shapefile:
geology_mask = [...
-1
votes
1
answer
2k
views
GeoJSON to masks [closed]
I need to use the GeoJSON file and TIFF images to produce masks. Is there a Python program that takes GeoJSON file and TIFF image as input and produces masks?
2
votes
1
answer
260
views
Issue while creating dataset mask for Landsat 7 ETM+ band data by using rasterio
I am trying to create dataset mask of a particular band of Landsat-7 (B2) & Landsat-8 (TIR) data and then plot the same using the following code:
For Landsat-7 Band-1:-
import rasterio
import ...
1
vote
0
answers
1k
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 ...
1
vote
0
answers
840
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
1
answer
401
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 ...
0
votes
1
answer
245
views
Not plotting NA-Values in raster with python
I have a raster that I cropped beforehand based on a shapefile with
gdalwarp -srcnodata '-1000 -255' -cutline {shape} {vrt_path} {tiff_path}
The thing is, that there are many NAs that get simply ...
4
votes
0
answers
866
views
Offset after clipping an image using rasterio.mask (illustrated with figures) [closed]
I want to clip an image named img_A of dimensions 14000x10000 using a polygon shape in order to get the same dimensions than another image named img_B of dimensions 1925x1372 (see figure 1 below). The ...
1
vote
0
answers
158
views
Defining invalid regions of VRT file with rasterio in a way that allows windowing [closed]
I'm using a VRT file to represent a bunch of individual map tiles as one big image. I noticed that some of the data is invalid but not marked as such (via the invalid data value). I'd like to define ...
2
votes
2
answers
922
views
Cropping raster using multiple shapefiles
I have a raster which I want to crop multiple times using different shapefiles. My code uses mask method which returns numpy array and its metadata:
out_img, out_transform = mask(raster=data, shapes=...
3
votes
1
answer
3k
views
Rasterio Write Masked Array to TIFF - Shape write and read indices are wrong [closed]
I'm clipping a raster to a shapefile, which returned a masked array, and my goal is to write that masked array to a new .tif file with the correct metadata. I can view the masked array and it looks ...
6
votes
1
answer
1k
views
Writing masked GeoTIFF in rasterio and visualizing in QGIS?
I have an interpolated raster, which is a masked array, that shows where the data is valid. I want to save it as masked TIFF with rasterio.
To test, here's the JSON file, and the code:
import rasterio,...
2
votes
2
answers
6k
views
Rasterio error: Input shapes do not overlap raster but reprojection not working
I'm trying to use rasterio (v1.0.13) and fiona to perform a raster clip on a geotiff using a geojson polygon. For reference, the clip works perfectly from the command line using GDAL:
gdalwarp -...
2
votes
1
answer
3k
views
Masking GeoTIFF file after GeoJSON through rasterio - "Input shapes do not overlap raster"
So my intention is quite simple:
I have a 4-Band TIFF file I want to crop after a polygon shape. However, I'm getting the following two exceptions
WindowError: windows do not intersect
ValueError: ...
1
vote
0
answers
385
views
Summarising all the (NDVI) values pixelwise for a masked polygon
A .tif image has been created using the NDVI formula in QGIS. The resulting image shows a region, with varying grades of NDVI values over the image. A .shp file has then been created for an area of ...
1
vote
0
answers
458
views
Does anyone know why I'm getting a completely black geotiff as a result of this shapefile cut out of another geotiff in rasterio?
I am using rasterio to cut out the shape of a lake outlined in my shapefile from a geotiff. When using a shapefile of a singular lake with a geotiff, this works perfectly, but not when cutting out a ...
6
votes
1
answer
641
views
Stacking and masking Landsat at the same time with rasterio
Based on answers from previous questions 1,2 and the Masking a raster using a shapefile guide from rasterio cookbook, I wrote the code below.
The code runs correctly. I would like to improve it.
1- ...
2
votes
1
answer
2k
views
Rasterio.mask returns error 'shapes are outside bounds of raster' - but they are definitely within raster bounds
I'm using rasterio.mask.mask to mask a raster with a shapefile.
import rasterio
import fiona
image_object = rasterio.open('/home/cate/image_name.img')
aoi_shapefile = fiona.open('/home/cate/AOI....
6
votes
1
answer
8k
views
rasterio masking with GeoJSON from file issue
I'm trying to load GeoJSON from a file for use with rasterio mask on a GeoTIFF and I can't seem to get the GeoJSON to load properly. I get this error:
File "/Users/user/example.py", line 18, in clip
...
1
vote
1
answer
1k
views
masking multiband with rasterio
I have 2 multiband rasters and I want to mask some areas of one of them with values of the other one, so I write this code (I can't figure out why is not working):
import os, rasterio
import numpy as ...