Book Image

PostGIS Cookbook

Book Image

PostGIS Cookbook

Overview of this book

Table of Contents (18 chapters)
PostGIS Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Importing netCDF datasets with Python and GDAL


In this recipe, you will write a Python script to import data from the netCDF format to PostGIS.

netCDF is an open standard format, widely used for scientific applications, that can contain multiple raster datasets, each composed of a spectrum of bands. For this purpose, you will use the GDAL Python bindings and the popular Numpy scientific library.

Getting ready

  1. If you are using Windows, be sure to install OSGeo4W, as suggested in the initial instructions of this chapter, that will include Python and GDAL Python bindings with Numpy support.

    For Linux users, if you did not do it, follow the initial instructions of this chapter and create a Python virtual environment, in order to keep a Python-isolated environment to be used for all the Python recipes of this book, and activate it:

    $ source postgis-cb-env/bin/activate
    
  2. For this recipe, you need the GDAL Python bindings and Numpy, the latest being needed by some GDAL methods (ReadAsArray) for arrays...