# PLMosaic (Planet Labs Mosaics API)

(GDAL/OGR >= 2.0)

This driver can connect to Planet Labs Mosaics API. GDAL/OGR must be built with Curl support in order for the PLMosaic driver to be compiled.

The driver supports listing mosaics and reading them. Mosaics are accessed at their highest resolution (Google Maps level 15, i.e. 4.77 meters/pixel). Mosaics are typically composed of quads of 4096x4096 pixels.

For mosaics of type Byte, overviews are available by using the tile API. For other data types, there is no support for overviews, so requests that involve downsampling may take a long time to complete.

## Dataset name syntax

The minimal syntax to open a datasource is :

    PLMosaic:[options]

Additional optional parameters can be specified after the ':' sign. Currently the following one is supported :

- api_key=value: To specify the Planet API key. It is mandatory, unless it is supplied through the open option API_KEY, or the configuration option PL_API_KEY.
- mosaic=mosaic_name: To specify the mosaic name.
- cache_path=path: To specify the path to a directory where cached quads (and tiles) are stored. A plmosaic_cache/{mosaic_name} subdirectory will be created under that path. The empty string can be used to disable any disk caching.
- trust_cache=YES/NO: Whether already cached quads should be reused directly, without prior checking if the server has a more recent version. Note: this only applies to quads, and not tiles. Default is NO.
- use_tiles=YES/NO: Whether to use the tile API to access full resolution data, instead of downloading quads. Only apply for Byte mosaics. Default is NO.

If several parameters are specified, they must be separated by a comma.

If no mosaic parameter is supplied, the list of available mosaics will be returned as subdatasets. If only one mosaic is available, it will be directly opened.

## Open options

The following open options are available : API_KEY, MOSAIC, CACHE_PATH, TRUST_CACHE and USE_TILES. They have the same semantics as the above describe parameters of same name.

## Configuration options

The following configuration options are available :

- PL_API_KEY=value: To specify the Planet API key.

## Location information

The special Pixel_{x}_{y} metadata item of the LocationInfo metadata domain, where x is the column and y is the line in the mosaic, can be queried to get information about the underneath quad and the scenes that compose it (only scenes whose footprint intersect the point are listed). This is the syntax used by the gdallocationinfo utility (see RFC 32)

Below an example of the return :

    <LocationInfo>
        <Quad>
            <id>L15-0455E-1272N</id>
            <file_size>9205776</file_size>
            <links_full>https://api.planet.com/v0/mosaics/color_balance_mosaic/quads/L15-0455E-1272N/full</links_full>
            <links_mosaic>https://api.planet.com/v0/mosaics/color_balance_mosaic</links_mosaic>
            <links_scenes>https://api.planet.com/v0/mosaics/color_balance_mosaic/quads/L15-0455E-1272N/scenes/</links_scenes>
            <links_self>https://api.planet.com/v0/mosaics/color_balance_mosaic/quads/L15-0455E-1272N</links_self>
            <links_thumbnail>https://api.planet.com/v0/mosaics/color_balance_mosaic/quads/L15-0455E-1272N/thumb</links_thumbnail>
            <num_input_scenes>5</num_input_scenes>
            <percent_covered>23.52</percent_covered>
            <geometry>POLYGON ((-100.019531236 40.04443758,-100.019531236 39.909736229899998,-99.843749986099994 39.909736229899998,-99.843749986099994 40.04443758,-100.019531236 40.04443758))</geometry>
        </Quad>
        <Scenes>
            <Scene>
                <id>20141014_165043_0908</id>
                <acquired>2014/10/14 16:50:43+00</acquired>
                <camera_bit_depth>8</camera_bit_depth>
                <camera_color_mode>RGB</camera_color_mode>
                <camera_exposure_time>1170</camera_exposure_time>
                <camera_gain>560</camera_gain>
                <camera_tdi_pulses>4</camera_tdi_pulses>
                <cloud_cover_estimated>0</cloud_cover_estimated>
                <data_products_analytic_full>https://api.planet.com/v0/scenes/ortho/20141014_165043_0908/full?product=analytic</data_products_analytic_full>
                <data_products_visual_full>https://api.planet.com/v0/scenes/ortho/20141014_165043_0908/full?product=visual</data_products_visual_full>
                <file_size>52363596</file_size>
                <image_statistics_gsd>4.22939278619</image_statistics_gsd>
                <image_statistics_image_quality>standard</image_statistics_image_quality>
                <image_statistics_snr>38.816414101138</image_statistics_snr>
                <links_full>https://api.planet.com/v0/scenes/ortho/20141014_165043_0908/full</links_full>
                <links_self>https://api.planet.com/v0/scenes/ortho/20141014_165043_0908</links_self>
                <links_square_thumbnail>https://api.planet.com/v0/scenes/ortho/20141014_165043_0908/square-thumb</links_square_thumbnail>
                <links_thumbnail>https://api.planet.com/v0/scenes/ortho/20141014_165043_0908/thumb</links_thumbnail>
                <quad_metadata_percentage_of_quad>1.72</quad_metadata_percentage_of_quad>
                <sat_alt>625.335328005</sat_alt>
                <sat_id>0908</sat_id>
                <sat_lat>39.929866991</sat_lat>
                <sat_lng>-99.7924758414</sat_lng>
                <sat_off_nadir>2.16630567839854</sat_off_nadir>
                <strip_id>1413305228.34946</strip_id>
                <sun_altitude>37.0861376836067</sun_altitude>
                <sun_azimuth>150.226745964007</sun_azimuth>
                <sun_local_time_of_day>10.1924460550178</sun_local_time_of_day>
                <geometry>POLYGON ((-99.972717127088671 39.955932287655287,-100.001449726838672 40.054504403484273,-100.15302892466832 40.028245144277392,-100.124005707005423 39.929632727481838,-99.972717127088671 39.955932287655287))</geometry>
            </Scene>
            <Scene>
                ...
            </Scene>
        </Scenes>
    </LocationInfo>

### Examples

- Listing all mosaics available (with the rights of the account) :

      gdalinfo "PLMosaic:" -oo API_KEY=some_value

  or

      gdalinfo "PLMosaic:api_key=some_value"

  or

      gdalinfo "PLMosaic:" --config PL_API_KEY some_value

  returns (in case of multiple mosaics):

      Driver: PLMOSAIC/Planet Labs Mosaics API
      Files: none associated
      Size is 512, 512
      Coordinate System is `'
      Image Structure Metadata:
        INTERLEAVE=PIXEL
      Subdatasets:
        SUBDATASET_1_NAME=PLMOSAIC:mosaic=color_balance_mosaic
        SUBDATASET_1_DESC=Color-Balanced Mosaic
        ...
      Corner Coordinates:
      Upper Left  (    0.0,    0.0)
      Lower Left  (    0.0,  512.0)
      Upper Right (  512.0,    0.0)
      Lower Right (  512.0,  512.0)
      Center      (  256.0,  256.0)

- Open a particular mosaic :

      gdalinfo "PLMosaic:mosaic=color_balance_mosaic" -oo API_KEY=some_value

  returns:

      Driver: PLMOSAIC/Planet Labs Mosaics API
      Files: none associated
      Size is 8388608, 8388608
      Coordinate System is:
      PROJCS["WGS 84 / Pseudo-Mercator",
          GEOGCS["WGS 84",
              DATUM["WGS_1984",
                  SPHEROID["WGS 84",6378137,298.257223563,
                      AUTHORITY["EPSG","7030"]],
                  AUTHORITY["EPSG","6326"]],
              PRIMEM["Greenwich",0,
                  AUTHORITY["EPSG","8901"]],
              UNIT["degree",0.0174532925199433,
                  AUTHORITY["EPSG","9122"]],
              AUTHORITY["EPSG","4326"]],
          PROJECTION["Mercator_1SP"],
          PARAMETER["central_meridian",0],
          PARAMETER["scale_factor",1],
          PARAMETER["false_easting",0],
          PARAMETER["false_northing",0],
          UNIT["metre",1,
              AUTHORITY["EPSG","9001"]],
          AXIS["X",EAST],
          AXIS["Y",NORTH],
          EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs"],
          AUTHORITY["EPSG","3857"]]
      Origin = (-20037508.339999999850988,20037508.339999999850988)
      Pixel Size = (4.777314267160000,-4.777314267160000)
      Metadata:
        FIRST_ACQUIRED=2014-03-20T15:57:11+00:00
        LAST_ACQUIRED=2015-04-06T11:38:16.570663+00:00
        TITLE=Color-Balanced Mosaic
      Image Structure Metadata:
        INTERLEAVE=PIXEL
      Corner Coordinates:
      Upper Left  (-20037508.340,20037508.340) (180d 0' 0.00"W, 85d 3' 4.06"N)
      Lower Left  (-20037508.340,-20037508.340) (180d 0' 0.00"W, 85d 3' 4.06"S)
      Upper Right (20037508.340,20037508.340) (180d 0' 0.00"E, 85d 3' 4.06"N)
      Lower Right (20037508.340,-20037508.340) (180d 0' 0.00"E, 85d 3' 4.06"S)
      Center      (   0.0000063,  -0.0000063) (  0d 0' 0.00"E,  0d 0' 0.00"S)
      Band 1 Block=256x256 Type=Byte, ColorInterp=Red
        Overviews: 4194304x4194304, ..., 256x256
        Mask Flags: PER_DATASET ALPHA
        Overviews of mask band: Overviews: 4194304x4194304, ..., 256x256
      Band 2 Block=256x256 Type=Byte, ColorInterp=Green
        Overviews: 4194304x4194304, ..., 256x256
        Mask Flags: PER_DATASET ALPHA
        Overviews of mask band: Overviews: 4194304x4194304, ..., 256x256
      Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
        Overviews: 4194304x4194304, ..., 256x256
        Mask Flags: PER_DATASET ALPHA
        Overviews of mask band: Overviews: 4194304x4194304, ..., 256x256
      Band 4 Block=256x256 Type=Byte, ColorInterp=Alpha
        Overviews: 4194304x4194304, ..., 256x256

  ## See Also

  - Documentation of Planet Mosaics API

  - API Authentication

  - Vector PLScenes / Planet Scenes API driver