Resource: HDX Resource

Description Details Public fields Methods Examples

Description

HDX Resource

HDX Resource

Details

HDX Resource

Public fields

data

placeholder for Resource field element

Methods

Public methods


Method new()

Create a new Resource object

Usage
Resource$new(initial_data = NULL, configuration = NULL)
Arguments
initial_data

list with required field to create a resource

configuration

a Configuration object

Returns

A new Resource object


Method download()

Download a HDX resource

Usage
Resource$download(
  folder = NULL,
  filename = NULL,
  quiet = TRUE,
  force = FALSE,
  ...
)
Arguments
folder

a character, folder to save the dataset

filename

a character, filename of the dataset

quiet

a logical value, silent download if TRUE

force

a logical value, force download

...

other download.file parameters

Returns

a character, the file path


Method download_folder()

Get the download folder for the latest downloaded resource

Usage
Resource$download_folder()
Returns

a character, folder with the latest downloaded resource


Method read_resource()

Read a Resource object directly into memory

Usage
Resource$read_resource(
  sheet = NULL,
  layer = NULL,
  download_folder = NULL,
  simplify_json = TRUE,
  force_download = FALSE,
  quiet_download = TRUE,
  ...
)
Arguments
sheet

a character value, only for resource in Excel format

layer

a character value, only for spatial (vector) resource

download_folder

a character value, folder to save the downloaded resource

simplify_json

a logical value

force_download

a logical value, if TRUE force download

quiet_download

a logical value, if TRUE silent download

...

other parameters to $download

Returns

a tibble, a sf, a stars or a list depending on the type of resource read


Method get_layers()

Get spatial (vector) resource list of layers

Usage
Resource$get_layers(
  download_folder = NULL,
  quiet_download = TRUE,
  force_download = FALSE,
  ...
)
Arguments
download_folder

a character value, folder to save the downloaded resource

quiet_download

a logical value, if TRUE silent download

force_download

a logical value, if TRUE force download

...

other parameters to $download

Returns

a the list of layers available in the resource


Method get_sheets()

Get the list of sheets name of resource

Usage
Resource$get_sheets(
  download_folder = NULL,
  quiet_download = TRUE,
  force_download = FALSE,
  ...
)
Arguments
download_folder

a character value, folder to save the downloaded resource

quiet_download

a logical value, if TRUE silent download

force_download

a logical value, if TRUE force download

...

other parameters to $download

Returns

a the list of layers available in the resource


Method get_dataset()

Get the resource dataset.

Usage
Resource$get_dataset()
Returns

a Dataset, the dataset containing the resource


Method get_required_fields()

Get dataset required fields

Usage
Resource$get_required_fields()
Returns

list of required fields for a resource


Method check_required_field()

Check dataset required field

Usage
Resource$check_required_field(check_dataset_id = FALSE)
Arguments
check_dataset_id

logical whether to check or not dataset id

Returns

a logical value, TRUE if the the resource is not missing a required field and throws an error otherwise


Method get_format()

Get the file format

Usage
Resource$get_format()
Returns

a character, the file format of the resource


Method as_list()

Get resource field into list

Usage
Resource$as_list()
Returns

a list with resource field


Method browse()

Browse the resource page on HDX

Usage
Resource$browse()

Method print()

Print a Resource object

Usage
Resource$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
Resource$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

1
2
3
4
5
6
## Not run: 
  set_rhdx_config()
  resource <- pull_resource("98aa1742-b5d3-40c3-94c6-01e31ded6e84")
  resource

## End(Not run)

dickoa/rhdx documentation built on May 7, 2020, 2 p.m.