Use the gdal provided by ubuntugis for installation.
First update the source of ubuntugis:
sudo add-apt-repository ppa:ubuntugis && sudo apt-get update
or
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable && sudo apt-get update
Here is a popular science PPA (taken from Baidu Encyclopedia):
Personal Package Archives (Personal Package Archives) is a service provided by the Ubuntu Launchpad website, which allows individual users to upload software source code, compile it through Launchpad and publish it as a binary package, as an apt/Synaptic source for other users Download and update. Every user and team on the Launchpad website can have one or more PPAs.
Then install the C++ version of GDAL:
sudo apt-get install gdal-bin
Then install GDAL's Python Wrapper package:
sudo pip install gdal
Use Eclipse+PyDev for development under Ubuntu.
See a small program:
from osgeo import gdal
file_path ='/home/theone/Data/GreatKhingan/DEM/Slope_GreatKhingan_500m.tif'
dataset = gdal.Open(file_path)print(type(dataset))
metadata = dataset.GetMetadata()print(metadata)
projection = dataset.GetProjection()print(projection)
operation result:
< class'osgeo.gdal.Dataset'>{'TIFFTAG_XRESOLUTION':'1','TIFFTAG_YRESOLUTION':'1','AREA_OR_POINT':'Area'}<type 'str'>
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]]
Recommended Posts