Created
February 16, 2016 19:57
-
-
Save zerebubuth/96d7d9ca8967e9f22cca to your computer and use it in GitHub Desktop.
Simple GDAL/numpy that doesn't seem to work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from osgeo import gdal | |
import numpy as np | |
import sys | |
xsize = 266 | |
ysize = 276 | |
drv = gdal.GetDriverByName("MEM") | |
ds = drv.Create('', xsize, ysize, 1, gdal.GDT_Float32) | |
band = ds.GetRasterBand(1) | |
arr = band.ReadAsArray(0, 0, xsize, ysize) | |
if (xsize, ysize) != arr.shape: | |
print>>sys.stderr, "%r != %r" % ((xsize, ysize), arr.shape) | |
raise Exception, "Array shape should match what we requested." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment