Skip to content

MrsPyramid Format

Tim Tisler edited this page Jan 15, 2015 · 13 revisions

##MrsPyramid Format

MrsPyramid is the data storage format for imagery within MrGeo.

###MrsPyramid MrsPyramid is based on the Tile Mapping System (TMS) concept described in Tile-Based Geospatial Information Systems - Principles and Practices, John T. Sample & Elias Ioup

A MrsPyramid consists of metadata and a series of MrsImage levels. Level 1 is the global level (lowest resolution) and consists of two tiles, each 180° square, making the total area of level 1 360° x 180°. Each lower level then bisects its parent in both latitude and longitude. The number of pixels in each tile must be square (identical in width and height) and isusually 512x512 pixels. The value was chosen at the best compromise between analytic throughput, where large tile sizes are preferred, and tile serving, where 256 or 512 square tiles are best. The tile size is configurable in the mrgeo.conf file for all images used, however the use of tile sizes other than 512 has never been adequately tested.

TMS Tiling Scheme

Ingested images are reprojected and stored as WGS-84 (EPSG:4326). They are also resized to the next highest (smaller pixel-size) zoom level. Images created through map-algebra will always use the highest zoom level of any input imagery.

Images can be any combination of pixel types, number of bands, and sample types (banded, interleaved, etc.). However, as of now, mapalgebra can only operate on a single band (band 1) of a multi-band image.

###MrsImage A MrsImage a single level of imagery within the MrsPyramid. It is a collection of key/value pairs, with the key being the tile-id, and the value being a Java Raster.

Each MrsImage is broken into tiles, based on the zoom level of the image. This allows fast, efficient serving of tiles in addition to efficient mapping/reducing. A particular tile x & y for any MrsImage at the same zoom level & tile size has the same geographic area! This means it is trivial to find the same area in multiple images; they have the same tile id.

The actual MrsImage is a combination of tile id, zoom level, tile size, an raster data. Tile id, zoom level, and tile size are used to place the particular raster data to a precise area on the globe.

Gotcha: The TMS scheme has pixel (0, 0) being at the lower-left corner (-180°, -90°). Rasters, on the other hand, have (0, 0) defined as the upper-left corner. Remember this, as it can lead to upside down images!

When used with the code, tile size and zoom level are integers, not stored within the tile itself, but rather passed around as parameters. Tile id is either a TileIdWritable, a long wrapped in a Hadoop Writable, or the long value itself. Using the zoom level, this can be split into the component tile x and y values. The raster data is usually passed around as a RasterWritable, a Hadoop Writable that has serialized the Java Raster into an array of bytes. This writable contains all the information needed to convert from the byte array into a Java Raster.

Common TMS Formulas