raster - xy rotated when using gdal.ReadAsArray in Python 2.7 -
i used gdal
module in python read dem raster. when under gdal
dem x , y sizes correct (42689, 35622). used readasarray function, shape of dem rotated (35622, 42689). there way fix or @ least identify how dem has been rotated?
in [54]: t1.rasterysize out[54]: 35622 in [55]: t1.rasterxsize out[55]: 42689 ta = t1.readasarray in [64]: ta.shape out[64]: (35622l, 42689l)
numpy has "y" axis axis 0 (the first axis), , "x" axis axis "1" (the second axis), 0-based index. when ask ta[3,1]
, coordinate x=1, y=3 origin (0,0) @ upper left. there has been no rotation, it's matter of convention.
you can plot dem using matplotlib
or save new raster using gdal
, see retained original orientation.
Comments
Post a Comment