Skip to content

Instantly share code, notes, and snippets.

View shanedoolane's full-sized avatar
🚜
Farming

Shane Dolan shanedoolane

🚜
Farming
  • Palo Alto, CA
  • 19:28 (UTC -07:00)
View GitHub Profile
@shanedoolane
shanedoolane / crop_geotiff.py
Created November 5, 2022 05:29 — forked from decrispell/crop_geotiff.py
quick and dirty geotiff crop using rasterio
import rasterio
# load the geotiff (a DSM in this case) and read the data - only one index in this case
dsm = rasterio.open(dsm_fname)
dsm_data = dsm.read()[0]
# crop the data
dsm_crop = dsm_data[min_y:min_y+height, min_x:min_x+width]
# make a copy of the geotiff metadata