HDX Resource

HDX Resource

Details

HDX Resource, it contains all the logic for creating, checking, and updating resources

Super class

rhdx::HDXObject -> HDXResource

Public fields

data

placeholder for Resource field element

Methods

Public methods

Inherited methods

Method new()

Create a new Resource object

Usage

HDXResource$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

HDXResource$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

HDXResource$download_folder()

Returns

a character, folder with the latest downloaded resource


Method read_resource()

Read a Resource object directly into memory

Usage

HDXResource$read_resource(
  sheet = NULL,
  layer = NULL,
  format = 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

format

a character value, file format;

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

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

HDXResource$get_layers(
  format = NULL,
  download_folder = NULL,
  quiet_download = TRUE,
  force_download = FALSE
)

Arguments

format

character; file format

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

Returns

a the list of layers available in the resource


Method get_sheets()

Get the list of sheets name of resource

Usage

HDXResource$get_sheets(
  format = NULL,
  download_folder = NULL,
  quiet_download = TRUE,
  force_download = FALSE
)

Arguments

format

character; file format

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

Returns

a the list of layers available in the resource


Method get_dataset()

Get the resource dataset.

Usage

HDXResource$get_dataset()

Returns

a Dataset, the dataset containing the resource


Method get_required_fields()

Get dataset required fields

Usage

HDXResource$get_required_fields()

Returns

list of required fields for a resource


Method check_required_field()

Check dataset required field

Usage

HDXResource$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

HDXResource$get_format()

Returns

a character, the file format of the resource


Method as_list()

Get resource field into list

Usage

HDXResource$as_list()

Returns

a list with resource field


Method browse()

Browse the resource page on HDX

Usage

HDXResource$browse()


Method print()

Print a Resource object

Usage

HDXResource$print()


Method clone()

The objects of this class are cloneable with this method.

Usage

HDXResource$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.