Scenes ExampleΒΆ

This example makes a simple request to our raster service and displays the image.

from pprint import pprint

from descarteslabs.scenes import Scene, display

scene, ctx = Scene.from_id("landsat:LC08:PRE:TOAR:meta_LC80330342017072_v1")

img, meta = scene.ndarray(
    bands=["swir1", "swir2", "nir"],
    ctx=ctx.assign(resolution=120),
    raster_info=True,
)

# visualize the image
display(img, size=2)
https://cdn.descarteslabs.com/docs/1.11.0/public/_images/sphx_glr_plot_hello_scenes_001.png

Out:

/home/stephen/.cache/bazel/_bazel_stephen/94c12998f847de25a1ba31a2db877e84/sandbox/linux-sandbox/333/execroot/monorepo/bazel-out/k8-opt/bin/docs/build_tools/public/descarteslabs/auth/auth.py:525: UserWarning: Failed to save token: [Errno 30] Read-only file system: '/home/stephen/.descarteslabs/.jwt_token_7eaadeabe2db39bce056de32ebf6475adcee6704.json.ps3u_y98'
  self._get_token()

We can also view the metadata returned by raster.

pprint(meta)

Out:

{'bands': [{'band': 1,
            'block': [128, 128],
            'colorInterpretation': 'Gray',
            'description': {'color': 'Gray',
                            'data_range': [0.0, 10000.0],
                            'dtype': 'UInt16',
                            'jpx_layer': 2,
                            'name': 'swir1',
                            'name_vendor': 'B6',
                            'res_factor': 2,
                            'srcband': 2,
                            'srcfile': 1,
                            'tags': ['spectral',
                                     'swir',
                                     'swir1',
                                     '30m',
                                     'landsat'],
                            'type': 'spectral',
                            'vendor_order': 6},
            'mask': {'flags': ['PER_DATASET', 'ALPHA'], 'overviews': []},
            'metadata': {},
            'overviews': [{'size': [7720, 7868]},
                          {'size': [3860, 3934]},
                          {'size': [1930, 1966]},
                          {'size': [966, 984]},
                          {'size': [484, 492]},
                          {'size': [242, 246]}],
            'type': 'UInt16'},
           {'band': 2,
            'block': [128, 128],
            'colorInterpretation': 'Gray',
            'description': {'color': 'Gray',
                            'data_range': [0.0, 10000.0],
                            'dtype': 'UInt16',
                            'jpx_layer': 2,
                            'name': 'swir2',
                            'name_vendor': 'B7',
                            'res_factor': 2,
                            'srcband': 3,
                            'srcfile': 1,
                            'tags': ['spectral',
                                     'swir',
                                     'swir2',
                                     '30m',
                                     'landsat'],
                            'type': 'spectral',
                            'vendor_order': 7},
            'mask': {'flags': ['PER_DATASET', 'ALPHA'], 'overviews': []},
            'metadata': {},
            'overviews': [{'size': [7720, 7868]},
                          {'size': [3860, 3934]},
                          {'size': [1930, 1966]},
                          {'size': [966, 984]},
                          {'size': [484, 492]},
                          {'size': [242, 246]}],
            'type': 'UInt16'},
           {'band': 3,
            'block': [128, 128],
            'colorInterpretation': 'Gray',
            'description': {'color': 'Gray',
                            'data_range': [0.0, 10000.0],
                            'dtype': 'UInt16',
                            'jpx_layer': 2,
                            'name': 'nir',
                            'name_vendor': 'B5',
                            'res_factor': 2,
                            'srcband': 1,
                            'srcfile': 1,
                            'tags': ['spectral',
                                     'nir',
                                     'near-infrared',
                                     '30m',
                                     'landsat'],
                            'type': 'spectral',
                            'vendor_order': 5},
            'mask': {'flags': ['PER_DATASET', 'ALPHA'], 'overviews': []},
            'metadata': {},
            'overviews': [{'size': [7720, 7868]},
                          {'size': [3860, 3934]},
                          {'size': [1930, 1966]},
                          {'size': [966, 984]},
                          {'size': [484, 492]},
                          {'size': [242, 246]}],
            'type': 'UInt16'},
           {'band': 4,
            'block': [128, 128],
            'colorInterpretation': 'Alpha',
            'description': {'color': 'Alpha',
                            'data_range': [0.0, 1.0],
                            'dtype': 'UInt16',
                            'jpx_layer': 1,
                            'name': 'alpha',
                            'res_factor': 1,
                            'srcband': 1,
                            'srcfile': 0,
                            'tags': ['mask', 'alpha', '15m', 'landsat'],
                            'type': 'mask'},
            'metadata': {},
            'overviews': [{'size': [7720, 7868]},
                          {'size': [3860, 3934]},
                          {'size': [1930, 1966]},
                          {'size': [966, 984]},
                          {'size': [484, 492]},
                          {'size': [242, 246]}],
            'type': 'UInt16'}],
 'coordinateSystem': {'dataAxisToSRSAxisMapping': [1, 2],
                      'epsg': 32613,
                      'proj4': '+proj=utm +zone=13 +datum=WGS84 +units=m '
                               '+no_defs',
                      'wkt': 'PROJCS["WGS 84 / UTM zone 13N",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["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-105],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32613"]]'},
 'cornerCoordinates': {'center': [488992.5, 4147087.5],
                       'lowerLeft': [373192.5, 4029067.5],
                       'lowerRight': [604792.5, 4029067.5],
                       'upperLeft': [373192.5, 4265107.5],
                       'upperRight': [604792.5, 4265107.5]},
 'driverLongName': 'Virtual Raster',
 'driverShortName': 'VRT',
 'geoTransform': [373192.5, 120.0, 0.0, 4265107.5, 0.0, -120.0],
 'metadata': {'GEOGCS': 'WGS 84',
              'GEOGCS|DATUM': 'WGS_1984',
              'GEOGCS|PRIMEM': 'Greenwich',
              'GEOGCS|SPHEROID': 'WGS 84',
              'PROJCS': 'WGS 84 / UTM zone 13N'},
 'size': [15440, 15736],
 'wgs84Extent': {'coordinates': [[[-106.4547242, 38.5253355],
                                  [-106.4140812, 36.3984047],
                                  [-103.8313659, 36.401059],
                                  [-103.7977729, 38.5282006],
                                  [-106.4547242, 38.5253355]]],
                 'type': 'Polygon'}}

Total running time of the script: ( 0 minutes 8.756 seconds)

Gallery generated by Sphinx-Gallery