rasterio

Create a raster from points (gpd.geodataframe object) in Python 3.6

Create a raster from points (gpd.geodataframe object) in Python 3.6 Question: I want to create a raster file (.tif) from a points file using a geopandas.geodataframe.GeoDataFrame object. My dataframe has two columns: [geometry] and [Value]. The goal is to make a 10m resolution raster in [geometry] point with the [Value] value. My dataset is: geometry …

Total answers: 2

How to make binary mask of large .tif file fast using .shp file with polygons (GPS coordinates)?

How to make binary mask of large .tif file fast using .shp file with polygons (GPS coordinates)? Question: I have a large .tif file (~24 Gb, more, than RAM could store) (Similar question: https://rasterio.readthedocs.io/en/latest/topics/masking-by-shapefile.html) (Method from library: https://rasterio.readthedocs.io/en/latest/topics/masking-by-shapefile.html) But I’m searching another faster solution. Maybe I should create numpy array with zeros and add polygon …

Total answers: 1

Update raster values using Python

Update raster values using Python Question: I’m trying to read in a raster file. It’s a 32-bit float raster, with either values 1 or no data. I want to update the values of 1 to 10, and write it out again (probably as a UNIT8 data type?). Here is my attempt: import rioxarray import numpy …

Total answers: 1

print the pixel coordinates of a specific point in the raster

print the pixel coordinates of a specific point in the raster Question: To print the pixel coordinates of a specific point in the raster, i used the index() method assuming that The index() method takes the x and y coordinates of the point in geographic coordinates and returns the corresponding row and column indices of …

Total answers: 1

Calculating NDVI using python results in all zeros

Calculating NDVI using python results in all zeros Question: I want to calculate the ndvi from a Sentinel-2 image. import os import numpy as np import rasterio as rio # suppress true divide warning numpy for 0 divide np.seterr(divide=’ignore’, invalid=’ignore’) red_f = absolute/path/to/band/4 nir_f = absolute/path/to/band/8 def calc_ndvi(): with rio.open(red_f) as src: red = src.read() …

Total answers: 1

Issues resampling raster to the resolution of another raster

Issues resampling raster to the resolution of another raster Question: I am trying to take a population raster and resample+reproject it to match the shape and resolution of a precipitation raster. Data Links: Population Data: https://figshare.com/ndownloader/files/10257111 Precipitation Data: https://www.ncei.noaa.gov/data/nclimgrid-monthly/access/nclimgrid_prcp.nc The Population Data is a series of rasters per decade of 5 different population models covering …

Total answers: 1

Resampling a raster using rasterio – simple modification of grid spacing

Resampling a raster using rasterio – simple modification of grid spacing Question: I am resampling raster data using Python’s rasterio. Looking at the rasterio.enums.Resampling class, it appears the only way to do this is to interpolate between adjacent raster grids, essentially smoothing the data. Is there some way to do a simple upsampling that effectively …

Total answers: 2

How to speed up extracting data from raster file for points using GDAL python

How to speed up extracting data from raster file for points using GDAL python Question: I have 366 raster image files (MODIS satellite daily data) in tif format containing snow data and another csv file containing 19,000 locations (latitude and longitudes). I need to collect the snow data from raster files. I have tried collecting …

Total answers: 2

Rasterio Geotiff Coordinate Translation

Rasterio Geotiff Coordinate Translation Question: I have some geotiff files but the coordinates are slightly off. I want to use rasterio’s API (or other python geo API like pygdal) to geometrically translate (shift) the image. For example, how do I move the image’s coordinates ‘north’ by a single pixel width. When displayed with a tool …

Total answers: 1