Python geospatial analysis and remote sensing toolkit
Pygaarst is a Python library to simplify the manipulation of remote sensing and other geospatial data. Features include data and metadata access for a number of frequently used freely available satellite remote sensing data such as Landsat TM/ETM+/OLI/TIRS, VIIRS, and MODIS; access and processing of generic raster formats such as GeoTIFF, HDF-EOS, HDF5 and netCDF and combination with vector formats such as ESRI Shapefile and GeoJSON; georeferencing and re-projecting; combining raster and vector datasets; mapping and plotting.
Pygaarst relies heavily on numpy for data structures and GDAL for data access and geospatial functionality. The main goal is to provide a friendly API that makes common tasks on widely used data formats easy to accomplish in few lines of code.
The project was initiated on 2013-09-18 and in an early stage of development.
The documentation for this project can be found [on ReadTheDocs] 2.
NOTE: Most of the dependencies require the isntallation of C (or even Fortran) libraries beforehand.
Pygaarst requires Python 2.7. Python 3(>=3.3) is planned.
For all raster handling:
- numpy
- GDAL for gdal, ogr and osr
- pyproj
For HDF5 rasters (such as VIIRS):
- h5py
For HDF4 rasters (such as MODIS, ASTER)
- python-hdf4
For vector overlays:
- Shapely
- Fiona
Future probably:
- netCDF4
For plotting and mapping:
- matplotlib and mpl_toolkits.basemap for
pygaarst.basemaputils
Documentation is also still in the very early stages of development.
The following modules are available and fulfil useful functions at the current time:
This module provides several classes to represent common raster dataset formats. Implemented currently:
class GeoTiff(object)
A generic representation of a GeoTIFF file.
Args: filepath - path to GeoTiff file
class HDF5(object)
A representation of a HDF5 data file. This is currently tailored to NPP/VIIRS SDR or EDR files.
Args: filepath - path to HDF5 file
class Landsatscene(object)
A representation of a Landsat 4, 5, 7 or 8 scene for TM, ETM+ or OLI/TIRS sensor data. Will parse the metadata file in both pre and post August 2012 formats.
Args: dirname - name of the directory to which the scene files are unzipped
Individual Landsat bands (for the above sensors and Landsat versions) can be accessed via:
class Landsatband(GeoTIFF)
A representation of a single-band dataset. Is aware of its metadata. Inherits from GeoTIFF
.
Further examples are provided in a [tutorial walkthrough] 1 of data access and map plotting for GeoTIFF and HDF5/VIIRS.
TODO:
- move the VIIRS-specific functionality to a separate class
- GeoTIFF improvements: clean handling of multiband datasets
- lat/long and native coordinate arrays for both "middle of pixel" and "corner" specs
- HDF-EOS, HDF4, netCDF
- MODIS and ASTER swath and gridded data including XML metadata file parsing
pygaarst.mtlutils.parsemeta(metadatafilepath)
Parses a metadata file and returns a dictionary of metadata values in the same
nested structure as the USGS metadata file decription language. Used for
pygaarst.raster.Landsatscene
, pygaarst.raster.ALIscene
and
pygaarst.raster.Hyperionscene
.
Contains some Landsat-specific data and helper functions that facilitate the conversion of digintal numbers (DN) to radiance, reflectance, and brighness temperature data, the calculation of vegetation indices and cloud masking.
Provides functions used by the pygaarst.raster.Landsatscene
and pygaarst.raster.Landsatband
classes, including:
pygaarst.landsatutils.get_bands(spacecraftid)
Returns permissible band labels (TM, ETM+ or OLI/TIRS) for a given spacecraft (L4, L5, L7 or L8).
pygaarst.landsatutils.getKconstants(spacecraftid)
Functions to work with infrared raster data.
pygaarst.irutils.gainbias(lmax, lmin, qcalmax, qcalmin)
pygaarst.irutils.dn2rad(data, gain, bias)
pygaarst.irutils.rad2kelvin(data, k1, k2)
pygaarst.irutils.rad2celsius(data, k1, k2)
TODO:
shapefile
classgeojson
class
pygaarst.basemaputils.map_interiorAK()
returns a Basmap object for a map of
the bulk of the Alaska mainland for convenient plotting.
(TODO: Other quick maps, possibility to override more parameters.)