bdc_coordinates_country_inconsistent: Identify records within a reference country

View source: R/bdc_coordinates_country_inconsistent.R

bdc_coordinates_country_inconsistentR Documentation

Identify records within a reference country

Description

This function flags geographic coordinates within a reference country. A spatial buffer can be added to the reference country to ensure that records in mangroves, marshes, estuaries, and records with low coordinate precision are not flagged as invalid.

Usage

bdc_coordinates_country_inconsistent(
  data,
  country_name,
  country = "country_suggested",
  lat = "decimalLatitude",
  lon = "decimalLongitude",
  dist = 0.1
)

Arguments

data

data.frame. Containing longitude and latitude. Coordinates must be expressed in decimal degrees and WGS84.

country_name

character string. Name of the country or countries to be considered.

country

character string. The column name with the country assignment of each record. It is recommended use a column with corrected and homogenized country names. Default = "country_suggested".

lat

character string. The column name with the latitude coordinates. Default = “decimallatitude”.

lon

character string. The column name with the longitude coordinates. Default = “decimallongitude”.

dist

numeric. The distance in decimal degrees used to created a buffer around the country. Default = 0.1 (~11 km at the equator).

Details

Multiple countries can be informed, but they are tested separately. The distance reported in the argument 'dist' is used to create a buffer around the reference country. Records within the reference country or at a specified distance from the coastline of the reference country (i.e., records within the buffer) are flagged as valid (TRUE). Note that records within the buffer but in other countries are flagged as invalid (FALSE). Records with invalid (e.g., NA or empty) and out-of-range coordinates are not tested and returned as TRUE.

Value

A data.frame containing the column '.coordinates_country_inconsistent'. Compliant (TRUE) if coordinates fall within the boundaries plus a specified distance (if 'dist' is supplied) of 'country_name'; otherwise "FALSE".

See Also

Other prefilter: bdc_basisOfRecords_notStandard(), bdc_coordinates_empty(), bdc_coordinates_from_locality(), bdc_coordinates_outOfRange(), bdc_coordinates_transposed(), bdc_country_standardized(), bdc_scientificName_empty()

Examples

## Not run: 
x <- data.frame(
  country = c("Brazil", "Brazil", "Bolivia", "Argentina", "Peru"),
  decimalLongitude = c(-40.6003, -39.6, -77.689288, NA, -76.352930),
  decimalLatitude = c(-19.9358, -13.016667, -20.5243, -35.345940, -11.851872)
)

bdc_coordinates_country_inconsistent(
  data = x,
  country_name = c("Brazil", "Peru", "Argentina"),
  country = "country",
  lon = "decimalLongitude",
  lat = "decimalLatitude",
  dist = 0.1 
)

## End(Not run)

brunobrr/bdc documentation built on Nov. 21, 2024, 4:18 a.m.