Questions tagged [rasterio]

open source Python library for reading and writing geospatial raster data

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

Array is visualized differently in matplotlib than QGIS

I am getting different resutls when plotting a np.array with matplotlib than when doing it in an external software - QGIS. Here is what I have: print(wiw[0].shape) (1, 8433, 9254) print(wiw[0]...
1
vote
1answer
26 views

Iterating through a matching set of before and after raster images in Python

I have downloaded a matching set of before and after insect invasion raster images from Google Earth Engine. I now want to loop through these images selecting the matching before and after invasion ...
2
votes
1answer
45 views

Output polygon is the inverse of what I need?

I am trying to output a different polygons from a single band GeoTIFF. I am trying output different polygons for specific range values such as 0.4 <= x < 0.5, 0.5 <= x < 0.6 etc (each ...
0
votes
1answer
18 views

rasterio reproject space value

I am using rasterio to reproject data from UTM to lat/lon. The reprojection work, but it creates projection space, with values of 0, which becomes a problem when I display the data, because some of ...
1
vote
0answers
27 views

NetCDF with negative dimensions

I am trying to read a NetCDF file with rasterio (Python), however, the resulting affine is showing negative numbers. The .nc4 file comes from NOAA. How can I correct these negative dimensions? nc_fo = ...
0
votes
1answer
34 views

Rasterio fails to create new tiff file inside for loop

I'm trying to save rasters with rasterio inside for loop. For reason that I don't understand, the for loop works only in the first loop (being able to save the tiff image) but then when comes to the ...
0
votes
0answers
14 views

Extracting elevation data from DEM with Python [duplicate]

I have downloaded a DEM model for a given region. I use rasterio like this: import rasterio dem_path = 'path_to_dem.TIF' list_of_points = ((42.136097, 24.742168),) def get_offline_elevation(...
1
vote
0answers
14 views

Can GeoTIFFs hold metadata on class labels?

I am creating GeoTIFFs in Python using rasterio and recently discovered that you can set band descriptions like so: with rio.open(out_tif, 'w', **profile) as dst: dst.write(data) dst....
0
votes
0answers
17 views

Why do I get (occasional) 404 errors when trying to access Sentinel-2 images using pystac-client

I use pystac-client to access some sentinel images. In Google Colab, I install pystac-client and rasterio by: %%shell pip install pystac-client pip install rasterio Import both modules: from ...
0
votes
0answers
13 views

Format rasterio Raster To Use In Further Operations

I am using this solution (with a couple of tweaks) to split my raster into tiles to further run operations on each tile. I am trying to figure out how to not have to write each split as a separate ...
0
votes
0answers
17 views

Coordinates accuracy in AutoCreateWarpedVRT

I have several dozen NTF files from the same rough geographic area. I open them using gdal.open(), source_ds = gdal.Open(str(ntf_path)) and they have valid GCPProjections (as far as I can tell): ...
0
votes
0answers
50 views

Reprojecting a numpy array from EPSG:32643 to EPSG:4326 [closed]

Below I have the given the numpy array in EPSG:32643 which I want to directly reproject to EPSG:4326 with Rasterio. Can anybody tell me how can I do so? array([[[878.65594, 878.6597 , 878.6628 , ..., ...
0
votes
1answer
22 views

Defining the CRS using rasterio when reading nongeoreferenced raster

I am trying to manually set the CRS of my rasterio object after reading in a png/pgw file. Of course, the pgw file contains the transformation for the raster but does not include any georeferencing/...
0
votes
1answer
21 views

Rioxarray.merge.merge_datasets unable to merge xarray datasets [closed]

I am working with geospatial data and have been previously using rasterio's merge function to join adjacent tiles together. For memory reasons I have switched from using in-memory rasters to xarray ...
0
votes
1answer
21 views

rioxarray: zero-size array to reduction operation minimum which has no identity

I'm trying to subtract one raster from another. They have a slightly different shape/extend but the same CRS/resolution. While attempting to subtract the raster, I received this error: 'zero-size ...
1
vote
0answers
22 views

Split Raster into Tiles - Set Extent

I am using this questions solution to split a raster I have into 1500x1500 tiles. The code works. I have recently been trying to figure out how to set the starting and ending points of the raster ...
1
vote
1answer
30 views

Extract multiband raster values to point shapefile

I am trying to extract multiband (3 bands) raster values to a point shapefile. In the following code, centroids_gdf is the variable that stores the point features. src stores a list coming from tifs ...
0
votes
1answer
19 views

Masking a NetCDF file 2D lat/lon with a shapefile in Python

I am trying to mask a NetCDF file with an shapefile. Here is my shapefile: Africa_Shape = geopandas.read_file('/content/gdrive/MyDrive/HighresMIP/control_1950/iho/iho.shp', crs="epsg:4326") ...
1
vote
1answer
24 views

Writing multiple python rasterio xarray results to file and naming each raster file

I am relatively new in using python for GIS, but I have the following code that I use to clip all created mosaics by a shapefile (aoi_shapefile). After the clipped rasters are placed in the rasterio ...
2
votes
2answers
76 views

Should reprojecting on the same ellipsoid be the identity operation, regardless of CRS?

I have images georeferenced to EPSG:32612 and coordinates in EPSG:4236. I see that both use the WGS84 ellipsoid. I want to convert the images to EPSG:4326 to mark positions in the images using lat/...
1
vote
1answer
28 views

TypeError: invalid driver when writing Rasterio created mosaic of Sentinel JP2's

The code below represents my attempt at mosaicing sentinel bands. I get an error right at the end when trying to write the mosaics. It states: TypeError: invalid driver: {'driver': 'GTiff', 'dtype':...
-1
votes
1answer
36 views

Any Python library that reads and resize the Sentinel 2 image with 10 bands

I found a Python library "imread" in github that reads raster image with more than 3 band. But it only does that I was wondering is there other library that resize the image like how we can ...
0
votes
1answer
27 views

Adjusting raster bounds in Python

I have what seems like it should be a simple issue, where all I need to do is adjust the bounds/extents of a given raster so that I can line it up with another. So, I may have a raster whose longitude ...
0
votes
0answers
29 views

Converting NetCDF and grid file downloaded from ECMWF - ERA5 hourly single level archived data to GeoTIFF format

I haven't worked much on GIS data. I have downloaded files from ECMWF portal from dataset - ERA5 hourly data on single levels from 1979 to present. I want to convert this file to GeoTIFF format so ...
0
votes
0answers
16 views

Empty resampled raster

I am following the code in rasterio documentation: https://rasterio.readthedocs.io/en/latest/topics/resampling.html#up-and-downsampling But I have to save the resampled raster. I read that we have to ...
0
votes
0answers
14 views

Split one TIFF file into multiple TIFF files using VRT file

I have a VRT file like below <VRTDataset rasterXSize="10801" rasterYSize="10801"> <SRS dataAxisToSRSAxisMapping="2,1">GEOGCS["WGS 84",DATUM["...
2
votes
0answers
25 views

Finding the bounds of a single pixel in a raster in Python

I have a satellite image and a group of polygons scattered around the image. The polygons are small and cover a single-pixel most of the time; I'm trying to create a new raster where each pixel value ...
0
votes
0answers
20 views

Why does rasterio compression reduces image size with single band but not with multiple bands

I downloaded Sentinel-2 data. This data have 13 files one for each band as jp2 format. I am reading this images the writing them as GeoTIFF format on python using rasterio. These images are large so I ...
2
votes
0answers
24 views

Aligning rasters in rasterio

I am struggling with a task that seems like it should be quite simple. I have two rasters with the same size, resolution, CSR, but slightly different bounds. I need to perform a fairly simple ...
0
votes
1answer
64 views

Point file to Raster conversion using "geocube"

Problem 1: Whenever I generate raster from a point using “geocube” I am noticing a shift in raster i.e., pixel center is not in line with the input point. Buffer snippet used is as follows Note: If ...
1
vote
1answer
17 views

Rasterio.merge removing images

I am experimenting with merging landsat bands. My dataset has several B3 bands close together, from landsat 8 and 7. import rasterio from rasterio.plot import show from rasterio.merge import merge ...
3
votes
1answer
80 views

Reproject NumPy ndarray without saving as TIFF

I have NumPy ndarray with shape (1063,2116,12) (has 12 bands). The ndarray has non geographical data, but I do have its' transform affine and the crs. I want to give this geographical data to the ...
1
vote
0answers
58 views

Wrong features when exporting vectorized raster data to a file using GeoPandas after applying a filter and a dissolve operation

I have a raster file with black areas having a value of 0 and white areas having a value of 1, resulting from a visibility analysis: I vectorized this raster after loading it with rasterio: import ...
0
votes
1answer
93 views

Copy metadata from one raster to another in rasterio using Python

I have two folders A and B. A contains a raster image with metadata and B contains the same raster images but with data, augmentation applied but with no metadata. One raster image in folder A is ...
0
votes
2answers
52 views

Type error for gdal- GDAL-style transforms have been deprecated

I'm trying to export numpy ndarray that I have to TIFF using rasterio. I have the transform of the image: print(transf) >>>(583932.1992386435, 10.0, 0, 2223772.1491772938, 0, -10.0) When I ...
1
vote
2answers
74 views

Plot shapely polygon on top of rasterio

I have 2D raster and I'm interested in plotting on top of it polygon. When I print the geometry and its' type I get this: #this is inside a loop that takes each time one row which is one polygon ...
1
vote
1answer
71 views

Transforming coordinates from one CRS to another with rasterio

I'm trying to merge some rasters with rasterio.merge.merge. They are in the same CRS, EPSG:3857. I want the merged raster to cover the whole earth. Exactly the range (in coordinates): xmin, ymin, xmax,...
0
votes
0answers
27 views

How to use disk files to replace memfile?

I am trying to collect Sentinel images and compute their NDVI which is done quite simply. However, I need to check determine all shapely multipolygons and map a NDVI value for each. I've decided to ...
0
votes
0answers
16 views

Find patches with data in raster and then extract those patches [duplicate]

I have a single band raster file as drawn in the labeled image attached. The size of raster is around 4k pixel in each x and y axis. Large part of this raster is empty. Only in small portions of the ...
0
votes
0answers
69 views

How to find patches with data in Raster and then how to extract those patches?

I have a single band raster file as drawn in the labeled image attached. The size of raster is around 4k pixel in each x and y axis. Large part of this raster is empty. Only in small portions of the ...
2
votes
2answers
90 views

Masking raster with a multipolygon

I have a .tiff and a multipolygon as a .shp. Both have been exported from QGIS using the same CRS (EPSG:3857). I load in the shapefile using GeoPandas and the TIFF using Rasterio. Then want to use the ...
3
votes
1answer
41 views

Rasterio misidentifying all pixels in band as Nodata

Main goal: Create pandas DataFrame from raster image - one row per pixel I have been using this resource Main problem: Rasterio is improperly marking every pixel as NoData instead of pulling the ...
3
votes
1answer
99 views

Cutting out polygon by GDAL in Python

I use the rasterio to cutting out polygons from TIFFs. The problem is rasterio is too slow. I am looking for something another and I would like to use GDAL but I don't know how to write the code. By ...
0
votes
0answers
40 views

Rasterstats: point_query performance

I register point_query (Rasterstats) as spark udf. My TIFF file size is 720 MB (Japan - entire country data) and trying to query and get raster value using point co ordinates (400K) records. It is ...
0
votes
0answers
21 views

How to raise an error that coordinates are out of raster bounds (rasterio.sample)?

I have some rasters from sentinel-2 mission that I'm working with. I'm using rasterio sample module , list_of_coords is just a list containing 3 random points but only 2nd is within the raster bounds: ...
1
vote
1answer
43 views

How to change the projections of a new raster

I tried to make an algorithm in Python where I entered a georeferenced raster (EPSG 32722 projection system), all its NaN values ​​were transformed to zero, and then a new image was saved with the ...
1
vote
1answer
36 views

Extract low resolution raster values within higher resolution multipolygon shapefile in Python

Fairly new to geoprocessing in general and within Python. I am using Python geoprocessing packages to extract meteorological information from a raster file within a watershed shapefile (the blue ...
0
votes
0answers
64 views

Rasterio: Input shapes do not overlap raster

I'm new to all of this, masking, rasterio package, etc. My intention is to mask a terrain with an image that has 6 bands. I am using this code: from rasterio.mask import mask bound_crs = boundary....
1
vote
1answer
24 views

Optimize sampling on band 1 of a big dataset

We do MANY samplings on band 1 of a big dataset, using rasterio dataset.sample function. (https://github.com/mapbox/rasterio/blob/master/rasterio/sample.py) Our python code looks something like this: ...
1
vote
0answers
43 views

Using rasterio and matplotlib to visualize Sentinel-1 data

I'm trying to work with satellite data for the first time and running into problems. I find the documentation about using Sentinel-1 data in Python lacking, but maybe I'm searching for the wrong ...

1
2 3 4 5
12