geowatch.demo package

Subpackages

Submodules

Module contents

Module for access to simple data for demo and testing purposes.

geowatch.demo.coerce_kwcoco(data='geowatch-msi', **kwargs)[source]

coerce with geowatch special datasets

Calls kwcoco.CocoDataset.coerce unless the code is geowatch-msi, and then we construct a special dataset with extra variables expected by the watch project.

Parameters:
  • data (str | Coercible[kwcoco.CocoDataset]) – the special code to coerce

  • **kwargs – modify how the demodata is created. For geowatch-msi, see demo_kwcoco_multisensor(), which has args like: dates, geodata, heatmap.

Example

>>> import geowatch
>>> dates=True
>>> geodata=True
>>> heatmap=True
>>> kwargs = {}
>>> coco_dset = geowatch.coerce_kwcoco(data='geowatch-msi', dates=dates, geodata=geodata, heatmap=heatmap)
>>> coco_dset2 = geowatch.coerce_kwcoco(data='geowatch-msi-dates-geodata-gsize32')
>>> assert 'date_captured' in coco_dset2.images().peek()
geowatch.demo.demo()[source]
Returns:

path to a demo stac catalog

Return type:

str

geowatch.demo.demo_kwcoco_multisensor(num_videos=4, num_frames=10, heatmap=False, dates=False, geodata=False, bad_nodata=False, **kwargs)[source]
Parameters:
  • num_videos (int) – number of videos in the demo dataset

  • num_frames (int) – number of frames per video in the demo dataset

  • heatmap (bool) – if True adds dummy saliency heatmaps to the demodata.

  • geodata (bool | dict) – if True adds dummy geographic referencing to the demodata. If a dictionary can specify extra information. Available keys:

    region_geom

  • bad_nodata (bool) – if True, zeros out some pixels which simulates bad nodata for testing.

  • dates (bool | dict) – Include time data or not. If a dictionary can specify extra information. Available keys:

    start_time end_time

  • **kwargs – additional arguments passed to kwcoco.CocoDataset.demo().

Returns:

kwcoco.CocoDataset

Example

>>> from geowatch.demo.smart_kwcoco_demodata import *  # NOQA
>>> num_frames = 10
>>> num_videos = 4
>>> dates=True
>>> geodata=True
>>> heatmap=True
>>> bad_nodata = True
>>> kwargs = {}
>>> coco_dset = demo_kwcoco_multisensor(dates=dates, geodata=geodata, heatmap=heatmap, bad_nodata=True)
geowatch.demo.demo_kwcoco_with_heatmaps(num_videos=1, num_frames=20, image_size=(512, 512))[source]

Return a dummy kwcoco file with special metdata

DEPRECATED:

Instead use geowatch.coerce_kwcoco(‘geowatch-msi-geodata-dates-heatmap-videos1-frames20-gsize512’) or something similar

Example

>>> from geowatch.demo.smart_kwcoco_demodata import *  # NOQA
>>> coco_dset = demo_kwcoco_with_heatmaps()

key = ‘salient’ for vidid in coco_dset.videos():

frames = [] for gid in coco_dset.images(video_id=vidid):

delayed = coco_dset.coco_image(gid).imdelay(channels=key, space=’video’) final = delayed.finalize() frames.append(final)

vid_stack = kwimage.stack_images_grid(frames, axis=1, pad=5, bg_value=1)

import kwplot kwplot.imshow(vid_stack)

geowatch.demo.dummy_rpc_geotiff_fpath()[source]

Create a blank tif with RPC information for testing

geowatch.demo.grab_landsat_product(product_id=None, demo_index=0)[source]

Download and cache all items for a landsat product.

Parameters:
  • product_id (str, default=None) – The product id to download (currently NotImplemented). If unspecified, an arbitrary scene is returned.

  • demo_index (int) – hack, can be 0, 1, or 2. Regions 1 and 2 should overlap.

Returns:

groupings of files associated with this landsat product

Return type:

Dict[str, object]

Example

>>> # xdoctest: +REQUIRES(--network)
>>> from geowatch.demo.landsat_demodata import *  # NOQA
>>> product = grab_landsat_product()
>>> # xdoctest: +IGNORE_WANT
>>> print('product = {}'.format(ub.urepr(product, nl=2)))
product = {
    'bands': [
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B1.TIF',
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B2.TIF',
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B3.TIF',
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B4.TIF',
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B5.TIF',
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B6.TIF',
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B7.TIF',
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B8.TIF',
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B9.TIF',
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B10.TIF',
        '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_B11.TIF',
    ],
    'meta': {
        'bqa': '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_BQA.TIF',
        'mtl': '.../LC08/01/037/029/LC08_L1TP_037029_20130602_20170310_01_T1/LC08_L1TP_037029_20130602_20170310_01_T1_MTL.txt',
    },
}

References

SeeAlso:

geowatch.gis.geotiff.parse_landsat_product_id

Todo

  • [ ] parametarize scene name / identifier

  • [ ] bundle bands in a single file (gdal VRT?)

  • [X] separate data and metadata files in return structure?

geowatch.demo.grab_nitf_fpath(key=None)[source]
Parameters:

key (str | None) – the name the nitf to grab. Use grab_nitf_fpath.keys() to list available keys. If None, DEFAULT_KEY is used.

Example

>>> # xdoctest: +SKIP
>>> # xdoctest: +REQUIRES(--network)
>>> from geowatch.demo.nitf_demodata import *  # NOQA
>>> fpath = grab_nitf_fpath()
>>> # xdoctest: +REQUIRES(--show)
>>> import kwplot
>>> import kwimage
>>> kwplot.autompl()
>>> data = kwimage.imread(fpath)
>>> kwplot.imshow(data)
>>> kwplot.show_if_requested()
geowatch.demo.grab_sentinel2_product(index=0, overwrite=False)[source]

Download and cache all items for a Sentinel-2 product.

TODO when RGD supports API keys, give one to this repo and use that instead of fels.

Parameters:
  • index – 0, 1, or 2. Currently this function just picks 3 scenes over KR in Nov 2018.

  • overwrite (bool, default=False) – if True, always downloads the files

Returns:

rgd_client.rgdc.RasterDownload(

path: pathlib.Path, images: List[pathlib.Path], ancillary: List[pathlib.Path]

)

Example

>>> # xdoctest: +SKIP("too many https errors")
>>> # xdoctest: +REQUIRES(--network)
>>> from geowatch.demo.sentinel2_demodata import *  # NOQA
>>> from geowatch.utils.util_rgdc import bands_sentinel2
>>> product = grab_sentinel2_product()
>>> assert len(bands_sentinel2(product)) == 13
SeeAlso:

geowatch.util.util_rgdc.bands_sentinel2

geowatch.demo.hack_seed_geometadata_in_dset(coco_dset, force=False, rng=None, region_geom=None)[source]

Add random geo coordinates to one asset in each video

Example

>>> from geowatch.demo.smart_kwcoco_demodata import *  # NOQA
>>> coco_dset = kwcoco.CocoDataset.demo('vidshapes5-multispectral')
>>> modified = hack_seed_geometadata_in_dset(coco_dset, force=True)
>>> fpath = modified[0]
>>> print(ub.cmd('gdalinfo ' + fpath)['out'])