NEWS


usgsm2m 0.2.0

Breaking changes

New

Bug fixes

The package is now organised around R6 objects rather than a flat set of functions. This is a breaking change: every exported ers_* function has been removed. See "Migrating from 0.1.0" below.

The pipeline

Getting data out of the M2M API takes several steps that have to happen in a particular order. That order is now expressed by the objects themselves, each stage returning an object whose methods are the valid next steps:

M2MSession → M2MDataset → M2MSceneSearch → M2MDownloadOptions → M2MDownloadQueue

Tab-completing $ shows only what you can legitimately do from where you are, and every object prints a Next: hint. A whole download now reads as one chain:

sess <- m2m_session()

queue <- sess$
  dataset("landsat_ot_c2_l2")$
  search(
    spatial  = filter_spatial(ll_lon = -120, ll_lat = 40, ur_lon = -119.5, ur_lat = 40.5),
    temporal = filter_temporal("2020-07-01", "2020-07-31"),
    cloud    = filter_cloud(0, 50)
  )$
  products()$
  select_bands(c("B4", "B5"))$
  filter(bulkAvailable)$
  request(label = "ndvi_july_2020")

queue$retrieve("data/")

Scene lists are now created for you. The M2M API requires one server-side before download options can be listed; $products() handles that, where previously you had to wire ers_scene_list_add() and ers_scene_products() together by hand and pass a list_id between them.

Migrating from 0.1.0

| 0.1.0 | 0.2.0 | |---|---| | ers_session() | m2m_session() | | ers_logout(s) | s$logout() | | ers_dataset(s, dataset_name = x) | s$dataset(x) | | ers_dataset_search(s, x) | s$find_datasets(x) | | ers_dataset_filters(s, x) | s$dataset(x)$filters() | | ers_scene_search(s, x, ...) | s$dataset(x)$search(...) | | ers_scene_list_add(s, x, scenes, id) | search$scene_list() | | ers_scene_list_get(s, id) | list$scenes() | | ers_scene_list_summary(s, id) | list$summary() | | ers_scene_list_remove(s, id) | list$remove() | | ers_scene_products(s, x, id, ...) | search$products() | | ers_download_request(s, p, label = l) | products$request(label = l) | | ers_download_queue(s, label = l) | s$download_queue(l) | | ers_download_search(s) | s$downloads() | | ers_download_retrieve(s, r, l, dir) | queue$retrieve(dir) | | ers_download_eula(s, code) | s$eula(code) | | ers_download_remove_order(s, l) | queue$cancel() | | ers_download_remove_items(s, ids) | (no direct equivalent; use queue$cancel()) |

filter_spatial(), filter_temporal() and filter_cloud() are unchanged.

The filter() S3 method for scene_products objects has been removed; M2MDownloadOptions$filter() replaces it.

New

Errors

API failures now raise conditions of class m2m_error, with m2m_http_error, m2m_api_error and m2m_not_found subclasses, instead of printing a message and returning NULL. A failed step stops the chain where it failed rather than surfacing later as an unrelated error:

tryCatch(
  sess$dataset("not_a_real_dataset"),
  m2m_not_found = function(e) message("No such dataset")
)

Bug fixes

Seven data-coercion bugs were found and fixed by testing against the live API across 20+ datasets. Several produced plausible but wrong data rather than failing, so results obtained with 0.1.0 are worth re-checking:

usgsm2m 0.1.0