Reading Raster Data with GDAL.pdf
介绍在Python中利用GDAL处理栅格数据的方法。十分有用。o RS/GIS LaboratoryUtah State UniversityFinding available formatsTo see what formats are compiled intoyour version of GDaL, use this commandin the FWTools shell (or terminal windowon a Mac)gda1info--f。 matsOS Python week 4: Reading raster data [3]www.gis.usu.eduo RS/GIS LaboratoryUtah State UniversityImporting GDALNeed to import both gdal and gdalconstFWToolsimport gdal, gdalconstNot fWtoolsfrom osgeo import gdal, gdalconstOS Python week 4: Reading raster data [4www.gis.usu.eduRS/GIS LaboratoryUtah State UniversityAll gdalconst constants start with a prefixwhich minimizes the possibility of conflictsWith other modulesCan import a module so you dont have toprefix things with the module nameimport gdalfrom gdalconst import*orfrom osgeo import gdalfrom osgeo. gdalconst import xOS Python week 4: Reading raster data [5]www.gis.usu.eduo RS/GIS LaboratoryUtah State UniversityGDAL data driversSimilar to ogr data driversNeed to register a driver before using itNeed to have a driver object beforecreating a new raster data setDriver names(code) are available athttp://www.gdal.org/formatslisthtmlOS Python week 4: Reading raster data [6]www.gis.usu.eduo RS/GIS LaboratoryUtah State UniversityRegister all drivers at onceWorks for reading data but not for creatingdata setsgdal. AlIRegister(Get the Imagine driver and register itWorks for reading and creating new Imaginefilesdriver gdal GetDriverByName('HFA)driver. Register()OS Python week 4: Reading raster data [7]www.gis.usu.eduo RS/GIS LaboratoryUtah State UniversityOpening a raster data setOnce the driver has been registered, theOpen(