Questions tagged [rasterio]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
18 views

How can I update a subset of raster values using open source python (rasterio, for instance)?

I have a source raster data set (tif file) and a number of polygon features. For each one of those polygons I need to: a) 'clip' the raster. b) change values of those clipped raster cells (with the ...
1
vote
0answers
38 views

Raster nodata = -3.4028234663852886e+38 [closed]

I'm very new to raster manipulation, and I'm getting a nodata value of -3.4028234663852886e+38 when importing USGS NED 1/3 arc-second n41w074 1 x 1 degree IMG using rasterio on Python. What is it ...
1
vote
1answer
45 views

Get Row/Column of Latitude/Longitude

I downloaded Sentinel-2 Imagery from AWS & I'm using rasterio to read/manipulate the data. I want to find the row/column coordinate of a latitude/longitude point that I initially used to search ...
4
votes
1answer
66 views

Extracting data within geometry (shape)

I have a NetCDF dataset which I normally call using the xarray function. I have recently been doing some transect analysis on the dataset, which looks something like this (the area between the ...
1
vote
0answers
32 views

Faster zonal stats for equal rasters with Python

I'm trying to extract data out of many raster images with different bounding boxes. Using the great rasterstats.zonal_stats it's a good approach, but it takes a considerable amount of time, especially ...
0
votes
0answers
26 views

Georeference an unreferenced image using rasterio in Python

I have unregistered/unreferenced 6 band TIFF images that I have been trying to export as georeferenced GeoTIFFs. The GPS coordinates of the corners of each image is known and each image is 1024 height ...
0
votes
0answers
19 views

How to add an extra layer of values to Sentinel 2 data

I'm working on Sentinel-2 data on water bodies. I collected the bathymetry information of a particular lake(which is having x,y,z. ie lat long and depth). Now I want to superimpose those depth values ...
0
votes
1answer
63 views

Transforming a image to a shape defined by image corners in earth coordinates - Python

I have a source satellite image. It is a rectangular shape x by y. I also have the stored lon/lat coordinates of the corners and the center point in the xml meta file. Is there a way with the gdal or ...
0
votes
0answers
41 views

How to downsample raster image for nightlights data in Python?

I'm working with the nightlights data - 30 arc second grids, spanning -180 to 180 degrees longitude and -65 to 75 degrees latitude. I want to downsample it to 5 arc-min resolution. Now my question is ...
3
votes
1answer
63 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
65 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 ...
1
vote
1answer
131 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
51 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
47 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
1answer
157 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 multi-band rasters from multiple GeoDataFrame columns (in polygon grid), but I have got stuck ...
0
votes
1answer
114 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
99 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
68 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
33 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
79 views

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

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
88 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
116 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
44 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
48 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
136 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
65 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
29 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
36 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
177 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
141 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
93 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
20 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
158 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
52 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
469 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
175 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
712 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
1k 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
72 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
304 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
125 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
271 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
38 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
180 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
226 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
251 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
325 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
113 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
324 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
239 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, ...