Skip to main content

This module pulls a panel of tile-composite images from MODIS satellites given latitude and longitude of the edges plus start and end dates.

Project description

TILESCRAPER

By Tavis Barr, tavisbarr@gmail.com, Copyright 2016 Licensed under the Lesser Gnu Public License V. 2.0 Contact me about other licensing arrangements

This program pulls images from the NASA MODIS satellite. See the satellite home page at http://modis.gsfc.nasa.gov/ for more information about its features and capabilities.

The purpose of the program is to simplify the process of downloading images. The interface provided by the web site allows for pulling images that match a pre-existing set of tiles whose boundaries are a bit opaque (but can be figured out with a bit of detective work). This program saves you the trouble of doing the detective work and allows you to pull the data given just the latitude/longitude of the image sides. Images are pulled at the highest possible resolution and then resized according to the command argument.

The next section describes the methods used; you can skip to the following section if you just want to use the program.

METHODOLOGY

The MODIS data are made available in tiles. There are several APIs available to pull these tiles; this package uses the REST API. See the MODIS web site for details on other APIs.

The MODIS data are given in layers, such as corrected reflectance, aerosol depth, etc. A complete list of available layers is available by using the getLayers() command. Different layers are available at different resolutions.

The layers can be accessed using different tile matrices. Each tile matrix represents a different image resolution. The first two tile matrices divide the world into two tiles (East/West) and eight tiles (two North/South by four East/West), respectively.

Tile matrix #3 is the lowest one that corresponds to specified resolution. The underlying assumption is that the image of the world (laid out like an orange peel onto a flat surface) can be represented by a 40940x20480 kilometer rectangle, with the equator and the Greenwich meridian as its centers. Tile matrix #3 is a matrix 10 tiles wide by 5 tiles high. This corresponds to an 8km resolution for each pixel, with each 512x512 tile representing a (512*8)x(512*8) = 4096x4096 kilometer region.

As the tile matrix number goes up, the number of tiles doubles and the resolution is cut in half. Thus, tile matrix #4 represents a 4km resolution, tile matrix #5 represents a 2km resolution, etc.

Of course, since the Earth is not flat, these resolutions are not exact. I assume they are correct at the Equator?

Given this information, it is easy to calculate the appropriate tiles for a given latitude and longitude of the border. The program then pastes the relevant tiles together, and crops any parts of tiles that are outside of the requested area.

METHODS

The following routines are available for this program:

getLayers() queries the MODIS web site to find out which layers are

available for download. The names of the layers are relatively intuitive, but one can visit the web site for further information.

The program uses a global variable, so the web site is only queried on the first call per execution.

getResolutions() returns a dictionary of the maximum available resolution

for each available layer.

getFormat() returns the image format that each layer is available in.

Different layers may be provided in a different format (jpeg, png, etc.).

getTileMatrix() returns the appropriate tile matrix corresponding to a

given resolution.

pullMosaic(layer , top , left , bottom , right , pull_year , pull_month , pull_day, imagewidth, imageheight)

pulls a single day’s tiles. Here, top/bottom/left/right are the latitude and longitude of the edges of the requested image. The year, month, and day are 4 digit year/numerical month (1 to 12). imagewidth and imageheight specify the resolution of the requested image, which is rescaled accordingly.

pullMosaicStream(

box, start_date, end_date, layer,prefix=”/tmp/image-“, extension=”.jpg”, output_size=(512,512)):

pulls a series of images of the same place for a given set of dates and puts them into the specified directory. box is a quadruple containing the edge latitude and longitude in the order (left, top, right, bottom). The start and end dates are given in SQL format, e.g., “2012-01-31”, the prefix should include both the directory where the images will be stored and any beginning to the filename, the extension will generally determine the image format, and output_size (the size of the image) is a duple (width, height).

loadStreamToIndexedArray(

start_date, end_date,prefix=”/tmp/image-“, extension=”.jpg”)

takes file set as created by pullMosaicStream() and creates a dictionary by date. Here, start_date is the date of the first image, in SQL format (e.g., “2012-01-31”); end_date is the date of last image; prefix is the directory and file prefix of the images, and extension is any file extension after the date, including the image type.

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

TileScraper-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

TileScraper-0.1.0-py2-none-any.whl (5.0 kB view details)

Uploaded Python 2

File details

Details for the file TileScraper-0.1.0.tar.gz.

File metadata

  • Download URL: TileScraper-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for TileScraper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a01628c5dbd5e1875b74b62a5ba7f87de147edda96dea9723cbd40dafb0b2db2
MD5 c8e9f708d344a107cb9d99fdcf8e742a
BLAKE2b-256 be8ae8943b041f10cb75ceb726b8304ecdc888ea87de32b6f2563b7e35237218

See more details on using hashes here.

File details

Details for the file TileScraper-0.1.0-py2-none-any.whl.

File metadata

File hashes

Hashes for TileScraper-0.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 901e59a2116298c99abfd36e709d2e7665ea6ddc10ef1b86531d34b436d3d068
MD5 f7d00822dee858a449f4114fe4e3181b
BLAKE2b-256 65bd9fa0cb387283197abad001aa86bd8afff794c31308a0fed880b140a7c006

See more details on using hashes here.

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