[Qgis-developer] Raster layer to numpy array

gene martin.laloux at gmail.com
Sat May 25 00:37:04 PDT 2013


For accessing raster files, the GDAL library is used. 

so:

   rasterPath = "the original path of your layer" 
   ds = gdal.Open("rasterPath")
   band1 = ds.GetRasterBand(1)  
   band2 = ds.GetRasterBand(2)  
   band3 = ds.GetRasterBand(3)  
 
and with numpy
   import numpy as np
   from osgeo import gdal
   ds = gdal.Open("rasterPath")
   band1 = np.array(ds.GetRasterBand(1).ReadAsArray())
   band2 = np.array(ds.GetRasterBand(2).ReadAsArray())
   band3 = np.array(ds.GetRasterBand(3).ReadAsArray())





--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Raster-layer-to-numpy-array-tp5055679p5055682.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.


More information about the Qgis-developer mailing list