Dataset class
Dataset class
Details
Definition for the Dataset class.
Note that this method has no effect if the dataset does not have
file path on disk.
Public fields
id
character identifier.
spatial_path
character file path.
attribute_path
character file path.
boundary_path
character file path.
spatial_data
NULL, sf::st_sf(), or terra::rast() object.
attribute_data
NULL, or tibble::tibble() object.
boundary_data
NULL, or Matrix::sparseMatrix() or NA object.
planning_unit_areas
NULL, or numeric vector of cached
planning unit areas, see get_planning_unit_areas().
Methods
Create a Dataset object.
Usage
Dataset$new(
id,
spatial_path,
attribute_path,
boundary_path,
spatial_data,
attribute_data,
boundary_data
)
Returns
A new Dataset object.
Method repr()
Generate a character summarizing the representation of the object.
Method import()
Import the data into memory.
Write the data to disk.
Usage
Dataset$write(spatial_path, attribute_path, boundary_path)
Arguments
spatial_path
character file path.
attribute_path
character file path.
boundary_path
character file path.
Method clean()
Clean the dataset from memory.
Method get_spatial_data()
Get the spatial data.
Usage
Dataset$get_spatial_data()
Method get_attribute_data()
Get the attribute data.
Usage
Dataset$get_attribute_data()
Method get_boundary_data()
Get the spatial data.
Usage
Dataset$get_boundary_data()
Method get_crs()
Get the coordinate reference system.
Method get_bbox()
Get the bounding box.
Usage
Dataset$get_bbox(native = TRUE, expand = FALSE)
Arguments
native
logical indicating if the bounding box should
be in (TRUE) the native coordinate reference system or (FALSE)
re-projected to longitude/latitude?
expand
FALSE should the bounding box be expanded by 10%?
Returns
list object with "xmin", "xmax", "ymin", and "ymax"
elements.
Method get_planning_unit_indices()
Get planning unit indices.
Usage
Dataset$get_planning_unit_indices()
Returns
integer vector of indices.
Method get_names()
Get attribute names.
Returns
character vector of field/layer names.
Method get_planning_unit_areas()
Get area values.
These are calculated once and then cached.
Usage
Dataset$get_planning_unit_areas()
Returns
numeric vector of values.
Method get_index()
Get a data from the dataset at an index.
Arguments
index
character or integer indicating the field/layer with
the data.
Method has_index()
Check if the dataset has an index.
Arguments
index
character or integer indicating the field/layer with
the data.
Returns
logical indicating if data is present or not.
Method max_index()
Maximum index.
Returns
integer largest index.
Method add_index()
Add data at an index.
Usage
Dataset$add_index(index, values)
Arguments
index
character or integer indicating the field/layer with
the data.
values
numeric vector.
Method update_bm()
Updates old boundary matrix to new format.
Method clone()
The objects of this class are cloneable with this method.
Usage
Dataset$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.