Stack Exchange Network

Stack Exchange network consists of 175 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

2
votes
0answers
10 views

Re-project GeoJSON from pixel-space to lat-long in Python

I have created a GeoJSON of linestrings in pixel space using Python. However, I now need to re-project the file to match the same projections and extent of the .tiff file I wish to layer the GeoJSON ...
3
votes
1answer
41 views

Error using rasterio's sample method

I'm using rasterio's sample function to get values from a (single-layer) raster based on a list of x,y locations: for val in myraster.sample(locations): print(val) This works fine for the first ...
0
votes
0answers
37 views

Converting NetCDF dataset array to GeoTiff using rasterio Python

I have read a NetCDF file using the netCDF4 library and then read one of its datasets ("Evapotranspiration") into a variable (variable contains array) using the following code. Subsequently now I am ...
1
vote
0answers
26 views

Python rasterio for saving GeoTIFF files and read in ArcGIS or QGIS

After following the steps in the tutorial of the Planet website (https://developers.planet.com/tutorials/convert-planetscope-imagery-from-radiance-to-reflectance/), I want to save each individual band ...
0
votes
0answers
26 views

Python rasterio save GeoTIFF files

After following the steps in the tutorial of the Planet website (https://developers.planet.com/tutorials/convert-planetscope-imagery-from-radiance-to-reflectance/), I want to save each individual band ...
2
votes
0answers
48 views

Rasterizing polygon grid in Python (geopandas & rasterio)

I am trying to rasterize a custom polygon grid with one or more columns. Preferably I'd like to create multiband rasters from multiple GeoDataFrame columns (in polygon grid), but I have got stuck even ...
0
votes
1answer
22 views

Writing a 3-band image with rasterio

I would like to save a 3-band raster to file using rasterio. The official docs have examples for saving a single band image in both the quickstart and in the advanced topics. What I would like to do ...
1
vote
1answer
39 views

Opening .vrt file with rasterio in Python?

I have 3 raster files (.tiff files) which are geographically 3 consecutive tiles of a particular area. I am trying to make a .vrt file of 2 out of these 3 files using the gdalbuildvrt python command. ...
0
votes
0answers
26 views

Plotting Multiple Rasters on Tkinter Canvas?

I have 2 Raster data sets (raster 1, raster 2) which are spatially adjacent to each other. As of now I am able to display individual raster on the tkinter canvas without any issues. What I am looking ...
1
vote
2answers
19 views

Storing image with rasterio as gtiff modifies image histogram

I'm trying to store and image as as gtiff, but the resulting image is changed, and I can't explain why. I'm reading sentinel jp2 band images using rasterio, I rescale these images from [0-10.000] to [...
1
vote
1answer
39 views

Sum the value of two raster files using Rasterio (Rasterio equivalent of Raster Calculator from ArcGIS)?

I'm trying to calculate the "real height" of a region, meaning I want to sum the elevation value and building height value, if there is any building, for a region. I know I can simply use Raster ...
0
votes
2answers
49 views

Resampling Sentinel-1 to Landsat 8 size and location

I am training a convolutional neural network to classify landcover and I would like to ingest both Landsat 8 and Sentinel-1 into my classifier. Currently it is working reasonably well for Landsat 8 ...
0
votes
1answer
45 views

Change CRS of large GeoTIFF and extract windows from large raster in Python

This is the first time I am working with GeoTIFF formats and I want to do this in Python. I am trying to use rasterio and pyproj for the following tasks. I have already made some first steps based on ...
1
vote
1answer
34 views

Open a mutliband raster, edit values in one of the bands, and overwrite the raster using Python/Rasterio?

I have numerous multiband rasters (36 band) in which preserving the band order is important for future processing. One of the bands often contains erroneous data and I'd like to be able to change all ...
1
vote
1answer
39 views

Automating calculation of NDVI with rasterio?

I want to automate this code below for other 99 images, the problem that I have is that each image is in its specific folder as it's mentioned in the picture below. the images are very big and I want ...
0
votes
1answer
70 views

Rasterio.features.rastersize

I have to transform the list of polygons that is in vector form into a raster mask that should be geographically aligned with the NDVI image that I have. I was advised to use rasterio.features....
0
votes
0answers
48 views

Different values between original raster and cropped raster with rasterio.mask

I have a large sentinel-2 image and I want to clip it according polygons which are stored in a geojson file. My code is: df = gpd.read_file(os.path.join(geojson_folder,geojson_file)) df.head() ...
0
votes
0answers
26 views

Would like to randomly sample points from within a polygon using Python [duplicate]

I would like to achieve something similar to the ArcGIS Create Random Points tool using geopandas, shapely, or rasterio. I aim to have a polygon with some holes in it (removed by subtracting buffered ...
0
votes
1answer
33 views

Rasterio resolution warping via CLI

I'm trying to warp a raster to meet an exact resolution (0.0022500000000000007, -0.0022499999999999977). I've tried using the CLI to no avail. The example in the docs is rio warp input.tif output....
1
vote
1answer
127 views

How to mosaic images with different CRS with rasterio

I am doing mosaicing of 14 raster images (.img format) to completely cover a province.see original spatial location of separately opened tiles(). Mosiac operation is completed but 4 tiles are mosiaced ...
1
vote
0answers
110 views

Rasterizing shapefile with rasterio and gdal gives all cells 0 values [closed]

I am trying to rasterize my shapefile (20 polygons) with rasterio and fiona and turn the new raster into a mask for clipping. I need to rasterize my all polygons in my shapefile and turn on mask ...
0
votes
0answers
84 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 ...
1
vote
0answers
17 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
126 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
39 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
281 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
121 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
496 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
646 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
69 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
vote
1answer
208 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
89 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=...
4
votes
1answer
164 views

Cannot upscale raster with rasterio

I am trying to upscale a raster using rasterio but I don't know 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 ...
1
vote
1answer
37 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
152 views

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

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
151 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
206 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 ...
1
vote
1answer
240 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
99 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
239 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
185 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
61 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
123 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 ...
2
votes
1answer
611 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 ...
1
vote
1answer
117 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
44 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 ...
2
votes
0answers
930 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
32 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
70 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
1answer
148 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 ...