Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [rasterio]

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

0
votes
0answers
24 views

How delete delete or mask nodata 0 value in the mask

I have raster (with 5 bands) and shapfile in the same projection. I do this script for rastersize and do mask and clip raster or crop raster with mask but I need to have just clip raster without black ...
0
votes
0answers
5 views

Rasterio CLI warping multiple rasters like another raster in all minus one feature

I'm writing a bash script to warp all the rasters in a specific directory to match another raster. I'd like to warp all these rasters iteratively in to match the other raster in all was except shape ...
3
votes
0answers
26 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 ...
1
vote
0answers
15 views

Reading a RasterIO MemoryFile triggers a GTiff driver warning/error message

I have recently upgraded RasterIO from version 1.0.5 to 1.0.12. After this upgrade I now get CPLE_NotSupported in driver GTiff does not support open option MODE when reading a MemoryFile. My code to ...
1
vote
2answers
44 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
1answer
36 views

Split GeoTIFF into multiple cells with Rasterio

I'd like to create training data for a machine learning pipeline. To do this I want to take a large raster and split it into multiple equal sized cells. I have a very basic loop for generating the ...
0
votes
1answer
41 views

Reading a 4 band image with rasterio (python)

I am trying to view a tif satellite image which has 4 bands. I want to remove the last band (NIR) and view the RGB image only, so I am trying to split the NIR from the rest of the image. Here is my ...
1
vote
1answer
53 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
1answer
41 views

Loading all rasters in a directory and naming the variables iteratively

Hi I'm working with prism data and I already have clipped (masked) rasters (*.bil files) of a specific area for each day of a year. I'd like to open all these rasters with rasterio, convert them into ...
-1
votes
0answers
34 views

Classifying/extracting land cover types and getting percentages from raster image?

I have a rather large raster image and I want to classify land cover types in the image. Land cover types such as: developed land, Planted/cultivated, barren, forest, shrubland, and water. I am not ...
0
votes
1answer
38 views

How to convert vector format (geopackage, shapefile) to raster format (geotiff) using rasterio without template raster

I'm looking to create a raster given just a geopackage (or shapefile, or other vector format). I don't have a template raster, and all I wish to do is burn the shapes into a raster using rasterio. ...
3
votes
1answer
43 views

How to use rasterio transform on all bands

I've imported a 10 band raster tif using rasterio as ds. I'm attempting to pad the image but keep getting errors with the transform. print(ds.transform) pilpadimg = rasterio.pad(ds.read(), transform=...
3
votes
1answer
37 views

cannot upscale raster with rasterio

I am trying to upscale a raster using rasterio but I don't now why my process gets killed. it can print "i am arrived here" but on the reproject() i have as terminal output killed This is the code ...
1
vote
1answer
32 views

cannot read raster of 14 MB

I would like to start using pure python to handle geospatial data since POSTGIS is not so optimized for rasters. I starting using rasterio and with this code : with rasterio.open(clc_r) as src: ...
3
votes
0answers
58 views

Using Rasterio to work with two rasters of different extent and resolution?

I have two spatial rasters of different extent and different cell size and I want to do a conditional statement with them. I decided to use rasterio for that. I use this code: with rasterio.open('A....
1
vote
1answer
58 views

Using rasterio and matplotlib how can I create a window for an NDVI image to fit into?

I am using Rasterio, Numpy, and Matplotlib. I created a window with the dimensions of 800x600 and plotted the band 5 for a Landsat 8 image, that worked just fine. I also have the nir image so then I ...
0
votes
1answer
78 views

Using Rasterio, Matplotlib, and Numpy trying to calculate and plot NDVI of a raster image getting error: IndexError: list index out of range?

First I create two variables and store my raster images in them and I use MatPlotLib to plot a subset of the original "nirband" raster image. That works fine. I am getting an IndexError: list index ...
0
votes
0answers
51 views

How to use Rasterio to display and save a subset Landsat image and compute and display its NDVI?

I have two Raster images, one from band 4 with a B4 at the end. And another from band 5 with B5 at the end. I want to subset the B5 raster to 800x600, then display it and save it as a GeoTiff. Then I ...
1
vote
1answer
71 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
1answer
55 views

Reprojection of satellite images mosaic to CRS with latitude and longitudes

I downloaded MODIS product MOD13A1 for India. Then mosaiced the granules in GeoTIFF format using rasterio Python library. I have the appropriate shapefile to mask the mosaiced raster. After mosaicing ...
1
vote
1answer
100 views

Creating subset of TIFF image and generating its NDVI in Python?

I have two Raster images, one from band4 with a B4 at the end and another with from band5 with B5 at the end. I want to subset the B5 raster to 800x600, then display it and save it as a GeoTiff. Then ...
0
votes
1answer
63 views

Rasterio showing single band images wrong

I'm using rasterio in Python at the moment, and I have no problem when I'm dealing with RGB satellite images. However, if I try using singleband Sentinel 2 images, or a singleband Sentinel 1 image, ...
1
vote
0answers
39 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
2answers
54 views

Unknown projection of GRIB file

I have issues extracting geometrical shaped data from a GRIB raster of soil moisture. The file is for example https://gimms.gsfc.nasa.gov/SMOS/jbolten/FAS/L03/20100113_20100115.as1.grib Using either ...
1
vote
1answer
113 views

Finding pixel location in raster using coordinates?

I'm not a GIS person. I haven't found or at least identified a solution to my problem, so decided to ask. I have a big rasters and a list of thousands of coordinates. I need to find the pixel ...
0
votes
1answer
34 views

Windowed writing in rasterio?

I have two large datasets, RP1 and RP2. I would like to subtract one from the other, however the datasets are extremely large and so exit out with a MemoryError when I try a direct read: RP1 = ...
0
votes
1answer
25 views

Windowed read of a raster producing wrong projection?

I'm using rasterio to read in a .tif file and converting it to vectors using the rasterio.features module. For a particularly large .tif file, I thought I'd use the windowed read option, but for some ...
1
vote
0answers
409 views

Error installing Rasterio in PyCharm and in CMD Line

Error installing Rasterio in PyCharm (Settings > Project Interpreter) Collecting rasterio Using cached https://files.pythonhosted.org/packages/1a/d5/...
1
vote
0answers
18 views

Geologica data UDM(unusable data mask) have 8 bits per pixel

UNUSABLE DATA MASK FILE(UDM) The unusable data mask file provides information on areas of unusable data within an image (e.g. cloud and non-imaged areas). The pixel size after orthorectification ...
0
votes
1answer
42 views

Generating a raster layer with intersecting line lengths as cell values

I have a polyline vector layer and a template raster dataset. For this polyline vector layer I would like to generate a new raster dataset based on the template raster dataset, but in which each cell ...
0
votes
0answers
21 views

Only Read Intersection of Two Rasters with rasterio

I am working with two data sets; Landsat 8 imagery for NDWI calculations, and land classification binary masks. I would like to use the land masks to produce numpy masked arrays of valid land and ice ...
0
votes
1answer
43 views

Making subset of Sentinel-2 with rasterio?

I am looking for a solution to my problem with rasterio. I want to download just a specific part of the image from AWS based on lat lon coordinates. Rasterio offers a great tool (window) although it ...
3
votes
0answers
51 views

Why can't I transpose a raster across the pole with rasterio or gdal, and how could it be done?

I have a raster in e.g epsg:4326, it covers all world, from 180E to 180W, from 90S to 90N. I want to re-project a part of it to epsg:3031 and also change the grid size and resolution. Here is a ...
0
votes
1answer
94 views

Rasterizing by attribute in rasterio

According to Rasterizing shapefiles with GDAL and Python? it seems that gdal allows rasterization of a layer according to a certain attribute ds = gdal.RasterizeLayer(target_ds, [1], source_layer, ...
0
votes
0answers
169 views

Rasterio : rasterio.drivers() - 'module' object is not callable [duplicate]

I'm trying to pass a script on jupyter-hub with a specific kernel. With my last local installation it worked but now with my kernel I have this error: TypeError ...
1
vote
0answers
65 views

Polygonizing raster cells in rasterio regardless of value?

I would like to polygonize every single cell of a raster dataset using rasterio. I have been experimenting with the following function based on this question: def polygonize_raster(dataset): # ...
1
vote
2answers
38 views

Unable to use GPS coordinates for GEOTiff map

I have been using a map to calculate some distances at sea. The map had a bit low resolution so I got another one with better resolution (both GEOTiff), but with the amounts of distances I need to ...
0
votes
1answer
45 views

How to convert masks generated by rasterio to channel last mask

The problem is about using rasterio to generate mask from GeoJSON file which contains geographic coordinates. The function that I used is from: from rasterio.tools.mask import mask with rasterio....
5
votes
1answer
199 views

Open a raster file with read and write permissions in rasterio

I am trying to write a function which will help me construct a rasterio memory file and return the dataset reader object so I can then play around with it as needed. I am trying to avoid with ...
2
votes
1answer
122 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 ...
1
vote
0answers
211 views

Writing numpy array to rasterio raster file generates empty file

I'm using Rasterio to read GeoTIFF from Sentinel 2 and calculating NDVI, but when I try to save as a new TIF file, the file turns to transparent and empty file. What am I missing? That's the code: ...
1
vote
0answers
32 views

rasterio & cogeo

I am trying to use rasterio to read cloud-optimized geotiff stored in a gc bucket. With method 1, GDAL makes use of the overviews and read is quick. Unfortunately, if the extent is not fully included ...
1
vote
0answers
38 views

rasterio - nodata per band [closed]

I am looking at a way to specify a different nodata value for each band in rasterio. I tried to: use the nodata key in the profile with a tuple or list of nodata values, set the nodatavals attribute,...
0
votes
0answers
70 views

Clipping raster with different UTM zones using rasterio?

I have 2 Landsat images, with an overlapping area: The one on the left is in WGS84 / UTM32N (EPSG:32632), the one on the right is in WGS84 / UTM33N (EPSG: 32633). I have a polygon in WGS84 / UTM33N (...
2
votes
1answer
194 views

How can I superimpose a geopandas dataframe on a raster plot?

I have a geopandas dataframe countries with country polygons, and a raster dataset raster (read with rasterio). I've already aligned the two as follows: countries = countries.to_crs(raster.crs.data) ...
1
vote
0answers
68 views

Reading a WMS/ raster map with rasterio

Can I read a raster map which has been constructed in mapserver as WMS with rasterio? rasterio.open ('http://...&service=WMS&request=GetMap&...FORMAT=image/tiff') I tried : from ...
0
votes
1answer
70 views

Extracting pixels in multiple rasters based on the values of another raster's pixels for time series analysis

I'm working with 52 rasters of a specific region over a period of one year in python. I also have a mask raster of the same area that is a binary color (250 black pixels for disparate areas of ...
0
votes
0answers
25 views

rasterio.warp.reporject: works incorrectly on big regions?

I want to reproject a big region of territory to ortho projection. For example, I take a raster of whole Earth in longlat projection and reproject it to ortho (make a view of whole Earth in ortho ...
0
votes
0answers
199 views

Opening numpy array to rasterio?

I have numpy array that I know bbox for and can transform like this: import rasterio.plot from rasterio.transform import from_bounds t = from_bounds(minx, miny, maxx, maxy, sorted_np[3,:,:,7].shape[...
1
vote
1answer
62 views

Take pixel locations from rasterio raster and write out shapefile

I'm pulling a satellite image into python with rasterio, running some analysis to find a specific bounding box within that image, and then want to write those points out as a shapefile. I'm struggling ...