1. 首页
  2. 课程学习
  3. 专业指导
  4. Reading Raster Data with GDAL.pdf

Reading Raster Data with GDAL.pdf

上传者: 2018-12-25 17:49:39上传 PDF文件 159.39KB 热度 26次
介绍在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(, )method can be used to return a datasetobjectfn =aster. imgds gdal Open(En, GA Readonly)if ds is Noneprint Could not open t fnsys. exit(1)OS Python week 4: Reading raster data [81www.gis.usu.eduo RS/GIS LaboratoryUtah State UniversityGetting image dimensionsDataset objects have propertiescorresponding to numbers of rowscolumns and bands in the data setcoLs=ds, RasterⅩSizerows s ds. rasterysizebands=ds, Raster coun七Notice no parentheses- because they'reproperties not methodsOS Python week 4: Reading raster data [9]www.gis.usu.eduo RS/GIS LaboratoryUtah State UniversityGetting georeference infoGeo Transforms are lists of informationused to georeference an imageFrom the gdal documentationadfGeoTransform[0] / top left x *adfGeoTransform[] /* w-e pixel resolution *adfGeoTransform[2] / rotation, 0 if image is " north up"*/adfGeoTransform[ 3] / top left y *adfGeoTransform[5] /*n-s pixel resolution /" north up"*/adfGeoTransform[4] / rotation, 0 if image isCoordinates are for top left corners ofpixels(unlike Imagine, which usescenters)OS Python week 4: Reading raster data [10]www.gis.usu.edu
用户评论