Skip to main content

Landsat raster file I/O

Project description

ESPA Tools

PyPI Build Status

An open-source Python package for simple loading of Landsat imagery as NumPy arrays

Install

espatools is available from PyPI:

$ pip install espatools

Usage

We think espatools is easy to use; give it a try and let us know what you think!

See this Jupyter Notebook for a demonstration of some simple plotting after reading Landsat imagery.

# Import the espatools module for raster I/O
import espatools
# Use matplotlib for simple plotting
import matplotlib.pyplot as plt

# Set the XML metadata file
xmlfile = 'LC081210652018073101RT-SC20180802013328/LC08_L1TP_121065_20180731_20180731_01_RT.xml'
# Set up the reader
reader = espatools.RasterSetReader(filename=xmlfile)
# Perfrom the read!
raster = reader.Read()

That's it! you just read in a set of Landsat imagery and each band is accessible by name as a 2D NumPy array:

# Get the bands dictionary
bands = raster.bands
# Grab a band by name
aer = bands.get('sr_aerosol')

# Plot this band up!
plt.imshow(aer.data)
plt.title(aer.name)
plt.show()

The above code results in an image like below:

aerosol

# Maybe you want the RGB bands as a 3D NumPy array
color = raster.GetRGB()

# You could plot this up:
plt.figure()
plt.imshow(color)
plt.title('color')
plt.show()

RGB

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

espatools-0.0.3.tar.gz (5.9 kB view details)

Uploaded Source

File details

Details for the file espatools-0.0.3.tar.gz.

File metadata

  • Download URL: espatools-0.0.3.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for espatools-0.0.3.tar.gz
Algorithm Hash digest
SHA256 db468dc205279a1a7ba2677cf8853c8280b084d7211be51991529be01c6b81f2
MD5 ff01a609716c2b80da3786a4b4d16681
BLAKE2b-256 f64476ffded6b3711ce8025fd0a36ff6820a60b202d1f3cedfb60be23022dde5

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page