items_sign_planetary_computer: Signs URL to access assets from Microsoft's Planetary...

View source: R/signatures.R

items_sign_planetary_computerR Documentation

Signs URL to access assets from Microsoft's Planetary Computer.

Description

These functions provide support to access assets from Planetary Computer.

  • items_sign_planetary_computer(): [Experimental] A simplified function to sign assets' URL from Microsoft Planetary Computer to be able to access the data.

  • sign_planetary_computer(): Creates a signing function to be used by items_sign(). This function sign all the assets' URL.

Usage

items_sign_planetary_computer(items, subscription_key = NULL, ...)

sign_planetary_computer(..., headers = NULL, token_url = NULL)

Arguments

items

a doc_item or doc_items object representing the result of ⁠/stac/search⁠, /collections/{collectionId}/items or /collections/{collectionId}/items/{itemId} endpoints.

subscription_key

the subscription-key to access restricted assets in Microsoft Planetary Computer. You can keep this parameter empty for non-protected assets.

...

additional parameters can be supplied to the GET function of the httr package.

headers

a named character vector with headers key-value content.

token_url

a character with the URL that generates the tokens in the Microsoft service. By default is used: "https://planetarycomputer.microsoft.com/api/sas/v1/token"

Value

  • items_sign_planetary_computer(): items with signed assets URLs.

  • sign_planetary_computer(): a function to to be passed to items_sign().

Examples

## Not run: 
 # doc_items object
 stac_obj <- stac("https://planetarycomputer.microsoft.com/api/stac/v1/") %>%
  stac_search(collections = "sentinel-2-l2a",
              bbox = c(-47.02148, -17.35063, -42.53906, -12.98314)) %>%
  get_request()

 # the new way to authenticate:
 stac_obj <- stac_obj %>%
   items_sign_planetary_computer()

 # this is the old way of authentication (still works):
 # stac_obj <- stac_obj %>%
 #   items_sign(sign_fn = sign_planetary_computer())

 # example of access to collections that require authentication
 stac_obj <- stac("https://planetarycomputer.microsoft.com/api/stac/v1") %>%
   stac_search(collections = c("sentinel-1-rtc"),
               bbox = c(-64.8597, -10.4919, -64.79272527, -10.4473),
               datetime = "2019-01-01/2019-01-28") %>%
   post_request()

 # the new way to authenticate:
 # stac_obj <- stac_obj %>%
 #   items_sign_planetary_computer("<subscription-key>")

 # this is the old way of authentication (still works):
 # stac_obj <- stac_obj %>%
 #   items_sign(
 #     sign_fn = sign_planetary_computer(
 #       headers = c("Ocp-Apim-Subscription-Key" = <your-mpc-token>)
 #     )
 #   )

## End(Not run)


rstac documentation built on Sept. 11, 2024, 7:03 p.m.