Writes the results of detect_native_coord() and/or
detect_native_country() to disk as gzip-compressed CSV files. Each
classification supplied produces two files: all of its classified records
and the native subset.
Arguments
- native_detected_coord
A
nativeDetectedobject returned bydetect_native_coord(), containing records with validated coordinates. It must carrygbifID,native_status,decimalLongitudeanddecimalLatitude, and none of its coordinates may be missing. Optional, but at least one ofnative_detected_coordandnative_detected_countrymust be supplied.- native_detected_country
A
nativeDetectedobject returned bydetect_native_country(), containing the records classified through theircountryCode. It must carrygbifIDandnative_status; missing coordinates are allowed. Optional, but at least one of the two classification arguments must be supplied.- export_path
Directory where the compressed CSV files should be written.
Details
Each classification supplied is written as its own pair of files, so the two sets never overwrite each other:
all_records_coord.csv.gz: every record classified bydetect_native_coord(), with all its columns and its native statusnative_records_coord.csv.gz: the subset of those records classified as"native"all_records_country.csv.gz: every record classified bydetect_native_country(), with all its columns and its native statusnative_records_country.csv.gz: the subset of those records classified as"native"
Only the pair belonging to a supplied argument is written, so supplying one argument leaves the files of the other untouched. The two sets are exported separately rather than bound together: this function never writes a combined table.
The two all_records_* files are likewise not a partition of a single input
and cannot be row-bound with each other. They carry different columns - the
coordinate result comes from CoordinateCleaned, whereas the country-code
result comes from CoordinateProblematic, which keeps its per-test verdict
columns - and detect_native_country() classifies only the records it
receives with a usable countryCode.
Both arguments already carry every column of the input records, so no join is performed here: each table is written straight from the object.
native_detected_coord must carry coordinates for every record: it is the
spatial output of detect_native_coord(), which only classifies records with
validated coordinates. The function stops if decimalLongitude or
decimalLatitude is missing for any of its records, which catches the two
arguments being swapped. native_detected_country carries no such
requirement, because detect_native_country() classifies the records that
failed coordinate validation - including records whose coordinates are
entirely absent.
Files are written with fwrite(encoding = "UTF-8"). export_path is
validated before writing: if it is not a single character path or exists as
a file (not a directory), the function stops with an error; if it does not
exist, a warning is emitted and the directory is created automatically.
