Book Image

Geospatial Development By Example with Python

By : Pablo Carreira
5 (1)
Book Image

Geospatial Development By Example with Python

5 (1)
By: Pablo Carreira

Overview of this book

From Python programming good practices to the advanced use of analysis packages, this book teaches you how to write applications that will perform complex geoprocessing tasks that can be replicated and reused. Much more than simple scripts, you will write functions to import data, create Python classes that represent your features, and learn how to combine and filter them. With pluggable mechanisms, you will learn how to visualize data and the results of analysis in beautiful maps that can be batch-generated and embedded into documents or web pages. Finally, you will learn how to consume and process an enormous amount of data very efficiently by using advanced tools and modern computers’ parallel processing capabilities.
Table of Contents (17 chapters)
Geospatial Development By Example with Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Installing GDAL and OGR


GDAL (Geospatial Data Abstraction Library) is composed of two packages that come together: OGR handles geospatial vector file formats, including coordinate system transformations and vector operations. GDAL is the raster part of the library, and in version 1.11, it comes packed with 139 drivers that can read, and some even create rasters. GDAL also comes packed with functions for raster transformations and calculations such as resizing, clipping, reprojecting, and so on.

In the following tables, there's an excerpt of the list of GDAL and OGR drivers with the most common formats that you may find:

Long format name

Code

Creation

Arc/Info ASCII Grid

AAIGrid

Yes

Arc/Info Export E00 GRID

E00GRID

No

ENVI .hdr Labelled Raster

ENVI

Yes

Generic Binary (.hdr Labelled)

GENBIN

No

Oracle Spatial GeoRaster

GEORASTER

Yes

GSat File Format

GFF

No

Graphics Interchange Format (.gif)

GIF

Yes

GMT Compatible netCDF

GMT

Yes

GRASS ASCII Grid

GRASSASCIIGrid

No

Golden Software ASCII Grid

GSAG

Yes

Golden Software Binary Grid

GSBG

Yes

Golden Software Surfer 7 Binary Grid

GS7BG

Yes

TIFF / BigTIFF / GeoTIFF (.tif)

GTiff

Yes

GXF (Grid eXchange File)

GXF

No

Erdas Imagine (.img)

HFA

Yes

JPEG JFIF (.jpg)

JPEG

Yes

NOAA Polar Orbiter Level 1b Data Set (AVHRR)

L1B

No

NOAA NGS Geoid Height Grids

NGSGEOID

No

NITF

NITF

Yes

NTv2 Datum Grid Shift

NTv2

Yes

PCI .aux Labelled

PAux

Yes

PCI Geomatics Database File

PCIDSK

Yes

PCRaster

PCRaster

Yes

Geospatial PDF

PDF

Yes

NASA Planetary Data System

PDS

No

Portable Network Graphics (.png)

PNG

Yes

R Object Data Store

R

Yes

Raster Matrix Format (*.rsw, .mtw)

RMF

Yes

RadarSat2 XML (product.xml)

RS2

No

Idrisi Raster

RST

Yes

SAGA GIS Binary format

SAGA

Yes

USGS SDTS DEM (*CATD.DDF)

SDTS

No

SGI Image Format

SGI

Yes

SRTM HGT Format

SRTMHGT

Yes

Terragen Heightfield (.ter)

TERRAGEN

Yes

USGS ASCII DEM / CDED (.dem)

USGSDEM

Yes

ASCII Gridded XYZ

XYZ

Yes

The following table describes the OGR drivers:

Format name

Code

Creation

Arc/Info Binary Coverage

AVCBin

No

Arc/Info .E00 (ASCII) Coverage

AVCE00

No

AutoCAD DXF

DXF

Yes

Comma Separated Value (.csv)

CSV

Yes

ESRI Shapefile

ESRI Shapefile

Yes

GeoJSON

GeoJSON

Yes

Géoconcept Export

Geoconcept

Yes

GeoRSS

GeoRSS

Yes

GML

GML

Yes

GMT

GMT

Yes

GPSBabel

GPSBabel

Yes

GPX

GPX

Yes

GPSTrackMaker (.gtm, .gtz)

GPSTrackMaker

Yes

Hydrographic Transfer Format

HTF

No

Idrisi Vector (.VCT)

Idrisi

No

KML

KML

Yes

Mapinfo File

MapInfo File

Yes

Microstation DGN

DGN

Yes

OpenAir

OpenAir

No

ESRI FileGDB

OpenFileGDB

No

PCI Geomatics Database File

PCIDSK

Yes

Geospatial PDF

PDF

Yes

PDS

PDS

No

PostgreSQL SQL dump

PGDump

Yes

U.S. Census TIGER/Line

TIGER

No

Note

You can find the full GDAL and OGR API documentation and the complete list of drivers at http://gdal.org/python/.

Windows

Again, we will use a wheel for the installation. Repeat the same procedure as before:

  1. Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/.

  2. Now, search for GDAL and download the file named GDAL‑1.11.3‑cp27‑none‑win32.whl.

  3. Finally, install it with pip, as we did before.

Ubuntu Linux

Perform the following steps:

  1. Go to the terminal or open a new one.

  2. Then, enter the following command:

    sudo apt-get install python-gdal