strLoc: Construct Locality String

View source: R/strLoc.R

strLocR Documentation

Construct Locality String

Description

The function combines the locality fields available to create the standard plantR locality string, which is used for the validate localities and geographical coordinates.

Usage

strLoc(
  x,
  adm.names = c("country.new", "stateProvince.new", "municipality.new"),
  loc.names = c("locality.new", "locality.scrap", "resol.orig")
)

Arguments

x

a data frame.

adm.names

a vector of columns names containing the country, state/province and municipality information, in this order. Defaults to 'country.new', 'stateProvince.new' and 'municipality.new'.

loc.names

an vector of columns names containing the locality (original and alternative) and the resolution of the locality information. Defaults to 'locality.new', 'locality.scrap' and 'resol.orig'.

Details

The function combines the locality information provided to create the standard string that plantR uses to retrieve information from its gazetteer. This string is built by concatenating the country, state, municipality and locality fields at the best resolution available. This nested format decreases the chances of retrieving information from localities with the same names in different regions. The standard gazetteer provided with plantR uses this standard locality string to make queries (see function getLoc() for details).

The input data frame should preferably be the output of the plantR function fixLoc(), as part of the validation workflow used by plantR. This function returns the edited locality fields (the function defaults) and, if chosen, an extra locality field. In this case, strLoc() also returns an alternative string ('loc.string2').

If used separately, users should provide a data frame with an specific set of column names (i.e. country.new, stateProvince.new, municipality.new, locality.new, and, if chosen, locality.scrap) or change the defaults. See examples below.

Value

The data frame x plus the locality strings constructed from the locality information ('loc.string', 'loc.string1' and 'loc.string2').

Author(s)

Renato A. F. de Lima

See Also

fixLoc and getLoc.

Examples


## Using the function separately (need to provide a data in a specific format)
# Creating a data frame with locality information
(df <- data.frame(country.new = c("brazil", "brazil", "brazil"),
stateProvince.new = c("rio de janeiro", "rio de janeiro", "rio de janeiro"),
municipality.new = c("parati", "paraty", "paraty"),
locality.new = c(NA,"paraty-mirim", NA),
locality.scrap = c(NA, NA, "trindade")))

# Creating locality strings used to query the gazetteer
strLoc(df)


## Using the function under the __plantR__ cleaning workflow
# Creating a data frame with locality information
(df <- data.frame(country = c("BR", "Brazil", "Brasil"),
stateProvince = c("RJ", "Rio de Janeiro", "Rio de Janeiro"),
municipality = c("Parati", "Paraty", "Paraty"),
locality = c(NA,"Paraty-Mirim", "Trindade")))

# Formating the locality information
df.fix <- fixLoc(df)

# Creating locality strings used to query the gazetteer
strLoc(df.fix)



LimaRAF/plantR documentation built on Jan. 1, 2023, 10:18 a.m.