Questions tagged [rasterio]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
42 views

Decimated and windowed read in rasterio

In my workflow using rasterio, I'd like to read an overview from a raster and get only a portion of it through a window at the same time. Is this possible? I have a pretty complex script so far and ...
0
votes
0answers
105 views

Problem Combining R, G, B Bands from JP2 Sentinel Imagery Into RGB Imagery

I have JP2 files from Sentinel-2 satellites that I need to combine into a single RGB image. I have tried a few different methods, which I will describe below; however, I keep running into issues. My ...
1
vote
2answers
118 views

How to clip an xarray to a smaller extent given the lat/lon coordinates?

I have a netcdf file showing elevation over Europe derived from GTopo30. Turns out that the extent of this raster file is too big to combine it with other layers, so I would like to crop it to a given ...
5
votes
1answer
93 views

Read pixel values of a raster image for given coordinates stored in a CSV file

I was trying to find the pixel values of several pixels whose coordinates are known. I did that in this way: import rasterio lons = [66.979, 69.2979, 67.2979 ] lats = [36.5854, 40.9854, 37.9854] ...
1
vote
0answers
67 views

Rasterio RGB band combo results in black TIFF

I am trying to to compose a RGB .TIFF image using rasterio with bands that I've downloaded from sentinel-2 (via sentinelsat). The resulting image is black. import rasterio # Open Bands 4, 3 and 2 ...
0
votes
0answers
34 views

Handling nodata values in raster in Python

I would like to set value of raster -999.0 as NaN in crop_image function, while reading/cropping file: for band_path in range_bands: # open raster as numpy array by rater.io in content manager(...
-2
votes
1answer
89 views

Using Python gdalwarp/rasterio to read gif file and world file, re-project to another picture [closed]

I want to re-project a radar image (https://radar.weather.gov/Conus/RadarImg/latest_radaronly.gif) which is in NAD83/EPSG4326 to WGS84/Pseudo-Mercator/EPSG3857. There is a world file associated with ...
0
votes
1answer
74 views

Rasterio: error when resampling a raster [closed]

I'm trying to resample a Sentinel 2 band using an upscale factor. I'm using the code exactly as in Rasterio documentation but I keep getting an error. Here is my code: import os import rasterio from ...
5
votes
4answers
395 views

Make shapefile from raster-bounds in Python

I have a raster that I opened with rasterio. When I do raster.bounds I get BoundingBox(left=399960.0, bottom=-3309780.0, right=609780.0, top=-3099960.0). My question is now, if there is any simple ...
6
votes
1answer
205 views

Multi-threaded compression in rasterio?

For writing large raster files (e.g. satellite image GeoTIFFs) to disk, the throughput rate tends to be limited by the compression algorithm rather than by the raw disk IO. (Benchmarks: 1, 2.) This is ...
0
votes
1answer
28 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 ...
1
vote
1answer
89 views

Converting gray band from dataset to RGB with rasterio for population density

I am seeking a solution that provides me a range of values rather than the provided 0 and 255 from rasterio. That most likely meant that I had to set the photometric and bands and ColorInterp to ...
0
votes
2answers
59 views

Combining two rasters based on a Condition using Open Source Python

I'm new to Python. My only experience is with Arcpy. I need to combine two rasters with the same extent into one output raster based on a condition. Using Arcpy, I would do something like this: ...
3
votes
1answer
92 views

What is the correct way to assign GeoPandas a CRS from Rasterio?

I'd like to be able to create a new GeoPandas object and inherit the CRS from Rasterio, and save a shapefile. The current projection format is seen as invalid when writing an ESRI driver. From here, ...
1
vote
0answers
27 views

Handling Nodata values in sklearn (working w pyimpute)

I'm using sklearn for a classification project. Because I'm relatively new to doing geospatial tasks outside of a GUI, I'm using Matt Perry's pyimpute (link has all the code for that module) to handle ...
2
votes
1answer
219 views

Using Rioxarray / QGIS Projection

For the past couple weeks I have been trying to view GOES17 data from netCDF files (converted to geotif) in QGIS 3.10 but cannot get the projection to work correctly. I have attempted numerous ...
2
votes
0answers
46 views

Polygonize every single pixel of a raster

How can I get every pixel separated? When I calc unique values, if two pixels have the same value, it converts in one row in the final shape. I need every single pixel converted into one unique ...
3
votes
1answer
54 views

Customized Web-based for data cube visualization [closed]

I am stepping into web mapping for the first time. I wanted to develop software for animating multi-spectral, multi-temporal data (in the form of an orthorectified data cube). User should be able to ...
3
votes
1answer
92 views

Unexpected result using rasterio windowed writing - Access window out of range in RasterIO()

I am trying to write (copy and paste) a raster into another raster using raserio's blocks and windows. I have two rasters (A and B): A has a greater extent than B and it completely contains B. The ...
0
votes
1answer
88 views

How can I overlay two raster without turning them in vector format in Python to get zone wise statistics?

I have two raster re-sampled and same extent one is elevation class raster from DEM reclassification classified in 10 zone with 500m interval and another is snow cover fraction raster has snow ...
3
votes
1answer
246 views

Merging rasters with rasterio in blocks to avoid MemoryError?

I am trying to merge two rasters with rasterio. However, when I run dest_array, out_transform = merge(sources), I receive the following error: MemoryError: Unable to allocate array with shape (1, ...
3
votes
1answer
75 views

Working with HDF4 file in GDAL

I'm definitely not the most experienced GDAL user, but I already struggle for quite a while now getting my head around the hdf4 file format in GDAL. The thing is that I have a directory with many hdf4 ...
0
votes
2answers
149 views

Extract population count from GeoTIFF based on mask layer

I downloaded Population Count data from Gridded Population of the World (GPW), v4 as a *.GeoTIFF file. In a next step, I would like to extract the population count of a given area based on a mask ...
0
votes
0answers
17 views

Change in Altitude Value of .tif file [duplicate]

I have a tif file of 7378 X 6923(widthXheight) resolution. I resized it to 1200 X 1200 pixels using Image class in python. img = Image.open('path to tif file') img = img.resize((1200,1200)) But ...
0
votes
1answer
82 views

Change in altitude value after resizing .tif file

I have a TIFF file of 7378x6923 (widthXheight) resolution. I resized it to 1200x1200 pixels using Image module in Python. img = Image.open('path to tif file') img = img.resize((1200,1200)) But after ...
2
votes
1answer
131 views

Rasterising multiple shapefiles into a single raster

I'm not even sure you can do this, but I want to convert multiple shapefiles into a single single-band raster. I'm pretty sure its going to be easier to first create a multi-band raster and then use ...
0
votes
1answer
123 views

Create VRT from multiple hdf files with Rasterio/GDAL

I have several Landsat 8 Scenes, each consisting of 11 bands. I want to mosaic them by creating a VRT and afterwards exporting the mosaic as TIFF again. I tried using GDAL via Python. But maybe it ...
0
votes
0answers
22 views

Convert list of .hdf-files to .vrt in python with Gdal

I'm a little lost. I have a directory with some Landsat-8-scenes. There are files that end on .hdf and they are always accompanied by a .hdr file. What I wanted to do is to convert these scenes to a ...
1
vote
1answer
125 views

How to write BIGTIFF raster files with rasterio

A few months ago I had a hard time in finding a way to read BIGTIFF files. In the end I only managed to do so by creating a new conda environment with the following options: conda create -n env_name ...
3
votes
1answer
84 views

Summing four rasters to one suitability raster using Rasterio & GeoPandas in Python

I am trying to create a basic suitability raster from three vector sources and one raster source using Rasterio & GeoPandas in Python. I have already clipped and rasterized the vector sources to ...
1
vote
1answer
111 views

Calculating NDVI using Rasterio, Python

Below is my code for calculating NDVI using Landsat 8. I have used band 4 and 5, but I am not getting any output. How should I get the output image? import numpy as np import rasterio import ...
0
votes
1answer
231 views

Plotting a polygon on a GeoTIFF [closed]

I am trying to use polygon coordinates to plot polygons on GeoTIFFs of satellite images using gdal or rasterio, yet somehow I keep failing. There is two things I want to do: create a mask with only ...
2
votes
1answer
100 views

Convert GDAL command line commands to Python script or code

I'm looking to convert my GDAL commands to Python code using either GDAL or Rasterio, as I've heard this is better to use. I've been scratching my head at this and I could be missing some simple ...
0
votes
1answer
39 views

How do I keep the coordinates while calculating tiles from a raster with Rasterio?

I'm trying to split a georeferenced TIFF image into several tiles for further processing. I have managed to calculate a single tile and give it the right CRS, evething fine so far. Once I load the ...
1
vote
1answer
382 views

Extract all pixels values from GeoTIFF with Python [closed]

I would like to recover the values of the pixels of a GeoTIFF of a single band. First I get the x and y coordinates and I would like to use them to access the pixel value. Here is my code: raster =...
1
vote
2answers
252 views

Overlay two raster GeoTIFFs using rasterio mask

I'm trying to crop two different geotiffs/rasters using a polygon with rasterio's mask function in order to get two corresponding/overlapping cropped numpy arrays of the same size/shape. The problem ...
1
vote
2answers
64 views

Huge GeoTIFF file after reprojecting file

I have some geotiff file. Their CRS ise EPSG:32635. I want to change crs to EPSG:4326. I use below script from Rasteri doc (link). In addition I added 'compress': 'lzw' to compress new geotiff file. ...
1
vote
1answer
74 views

Creating custom proj4 string from components

I'm trying to work with NOAA's NDFD weather data, which are released as rasters in GRIB format. Specifically, I'm currently trying to get the pixels that intersect an arbitrary geometry. Information ...
1
vote
0answers
41 views

Rasterio 0-360 lon inputfile to -180:180lon WarpedVRT output

I have used rasterio to open netcdf files and by defining a WarpedVRT extract a subarea that can be read with the vrt.read() command. It works like a charm except when the longitude grid is 0:360 ...
1
vote
2answers
124 views

Reading raster values in points gives back a generator object instead of actual value

Given a raster TIF file and a point feature class in a geodatabase, I am trying to extract the values of the raster on the points and add them as a new column on the point feature class. I am using ...
2
votes
0answers
66 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
1answer
41 views

Loading a section of JPEG2000 raster

I have a raster band saved as a .jp2 which I downloaded from Sentinel2-L2A. I can load it using rasterIO: with rasterio.open(path_to_jp2) as src: img = src.read(1) This works fine, however, it ...
1
vote
0answers
25 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
1answer
179 views

Building Raster Attribute Table (RAT) from GeoPandas dataframe with rasterio or GDAL

I am trying to figure out how to generate a RAT for a 1-band raster with rasterio or GDAL given a GeoPandas dataframe. My GeoPandas dataframe has 4 columns (X, Y, PERC_VALUE, LANDUSE_LABEL) which I ...
0
votes
1answer
181 views

Open a GDAL dataset with rasterio.open()

I am processing geotiff files with GDAL and rasterio. Every process of my processing chain generates a file in output. What I want is saving every file in memory instead of creating files in the disk. ...
2
votes
0answers
184 views

Plotting GoeDataFrame on a raster

I have a bunch of polygons which I loaded from a shapefile into a fields GeoDataFrame: geometry raster_val 0 POLYGON ((8.56799 47.80800, 8.56799 47.77200,...
1
vote
1answer
135 views

module 'rasterio' has no attribute 'open'

I am new to rasterio. I'm trying to open a tif file using this code: import rasterio dataset= rasterio.open('/home/zaianir/Documents/DB/serie_temporelle_s2/serie_temporelle_s2/Sentinel2_T31TCJ_MASKS....
1
vote
0answers
399 views

Installing Rasterio and GDAL API in a virtuallenv in Windows 10

Following rasterio installation guidelines (rasterio.readthedocs.io) I downloaded the relevant wheel files from Cristoph's list (link) and installed them successfully on my Windows 10 system. Yet I ...
2
votes
1answer
1k views

Convert GeoJSON to GeoPandas GeoDataframe

I created the following GeoJSON object with this code: from rasterio.features import shapes polys = [] for shape, value in shapes(segments, transform=affine): polys.append(shape) [{'type': '...
1
vote
0answers
113 views

Converting GeoJSON to a raster image using rasterio [closed]

My geospatial data knowledge is limited. I am hoping for advice as to how I can convert the full GeoJSON geometry into a tif image using rasterio. I have tried using gdal_rasterize to no avail. Not ...

1
2
3 4 5
7