GDAL的python版本安装使用

        首先,编译Python版本的GDAL,具体编译可以参考之前的博客GDAL之Swig编译里面的内容,网址是:http://blog.csdn.net/liminlu0314/article/details/6945452。或者下载别人编译好的版本。

        然后将下载下来的文件,全部复制到Python的安装目录下的 Lib\site-packages文件夹中,即可,如下图:

        然后,打开Python,输入:

        import osgeo.gdal

        回车,如果提示错误,说明没有安装成功,如果没有提示,说明安装成功。一段测试代码:

from osgeo import gdal
from osgeo.gdalconst import *
dataset=gdal.Open("F:\Work\Data\envi.img",GA_ReadOnly)
dataset.GetDriver().ShortName
#'ENVI' #图像格式
dataset.GetProjectionRef()
#'PROJCS["unnamed",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4269"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",30],PARAMETER["central_meridian",-84.16666666666667],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",2296587.926509186],PARAMETER["false_northing",0],UNIT["Foot (International)",0.3048]]' #图像投影信息

转载自:https://blog.csdn.net/liminlu0314/article/details/7310651

You may also like...