Harmonise and integrate geometries in a standardised format
normGeometry(
input = NULL,
...,
thresh = 10,
outType = "gpkg",
pattern = NULL,
update = FALSE,
verbose = FALSE
)
[character(1)
] path of the file to normalise. If this
is left empty, all files at stage two as subset by pattern
are
chosen.
[character(.)
] a subset of administrative units as given
by nation
, continent
, region
, subregion
or
un_member = TRUE/FALSE
. Valid selection criteria and their values
are in the object countries
.
[integerish(1)
] the deviation of percentage of
overlap above which to consider two territorial units "different".
[character(1)
] the output file-type, see
st_drivers
for a list. If a file-type supports layers, they
are stored in the same file, otherwise the different layers are provided
separately. For an R-based workflow, "rds"
could be an efficient
option.
[character(1)
] an optional regular expression. Only
dataset names which match the regular expression will be returned.
[logical(1)
] whether or not the physical files should
be updated (TRUE
) or the function should merely return the geometry
inventory of the handled files (FALSE
, default). This is helpful to
check whether the metadata specification and the provided file(s) are
properly specified.
[logical(1)
] be verbose about what is happening
(default FALSE
). Furthermore, you can use
suppressMessages
to make this function completely silent.
This function harmonises and integrates so far unprocessed geometries at stage two into stage three of the geospatial database. It produces for each nation in the registered geometries a spatial file of the specified file-type.
To normalise geometries, this function proceeds as follows:
Read in input
and extract initial metadata from
the file name.
Loop through every nation potentially included in the file that shall be processed and carry out the following steps:
In case the geometries are provided as a list of simple feature POLYGONS, they are dissolved into a single MULTIPOLYGON per nation.
In case the nation to which a geometry belongs has not yet been created at stage three, the following steps are carried out:
Check whether the recent dataset is GADM, to build the initial administrative hierarchy from GADM geometries, and stop if this is not the case.
Extract the full hierarchy of all territorial units that are part of the geometry.
Reconstruct ahID from the intermediate spatial objects and from the metadata.
In case the nation to which the geometry belongs has already been created, the following steps are carried out:
Check whether the new geometries have the same coordinate reference system as the already existing database and re-project the new geometries if this is not the case.
Check whether all new geometries are already exactly matched spatially and stop if that is the case.
Check whether the new geometries are all within the already defined parents, and save those that are not as a new geometry.
Calculate spatial overlap and
distinguish the geometries into those that overlap with more and those with
less than thresh
.
For all units that did match, copy ahID from the geometries they overlap.
For all units that did not match, rebuild metadata and a new ahID.
If update = TRUE, store the processed geometry at stage three.
Move the geometry to the folder '/processed', if it is fully processed.
Other normalisers:
normTable()
# NOT RUN {
library(sf)
# build the example database
makeExampleDB(until = "regGeometry")
# normalise all geometries ...
normGeometry(nation = "estonia", update = TRUE)
# ... and check the result
st_layers(paste0(tempdir(), "/newDB/adb_geometries/stage3/Estonia.gpkg"))
output <- st_read(paste0(tempdir(), "/newDB/adb_geometries/stage3/Estonia.gpkg"))
# }
Run the code above in your browser using DataLab