Skip to content

Instantly share code, notes, and snippets.

@sixy6e
Last active August 29, 2015 14:10
Show Gist options
  • Save sixy6e/f9d28ecf57a5b0788737 to your computer and use it in GitHub Desktop.
Save sixy6e/f9d28ecf57a5b0788737 to your computer and use it in GitHub Desktop.
reading an image subset and returning a geobox instead of separate geotransform and projection items
from GriddedGeoBox import GriddedGeoBox
from io import read_subset
import rasterio
fname = '/g/data/v10/eoancillarydata/Land_Sea_Rasters/WORLDzone56.tif'
ds = rasterio.open(fname)
gb = GriddedGeoBox.from_dataset(ds)
gb.origin
ds.get_transform()
q = read_subset(fname, gb.convert_coordinates((100,100)), gb.convert_coordinates((200,100)), gb.convert_coordinates((200,200)), gb.convert_coordinates((100,200)))
q[1]
q[-1].origin
@sixy6e
Copy link
Author

sixy6e commented Nov 24, 2014

The geobox changes the UL origin which subsequently changes any pixel to map conversions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment