Skip to contents

Utility to identify lat and lon columns, renaming and cleaning them up.

Usage

latlon_df_clean(df, invalid_msg_table = FALSE, set_invalid_to_na = TRUE)

Arguments

df

data.frame With columns lat and lon or names that can be interpreted as such

invalid_msg_table

Set to TRUE to add columns "valid" and "invalid_msg" to output

set_invalid_to_na

if not set FALSE, it replaces invalid lat or lon with NA values

Value

Returns the same data.frame but with relevant colnames changed to lat and lon, and invalid lat or lon values cleaned up if possible or else replaced with NA, and optional columns "valid" and "invalid_msg"

Details

Tries to figure out which columns seem to have lat lon values, renames those in the data.frame. Cleans up lat and lon values (removes extra characters, makes numeric)

Examples

#  x <- latlon_df_clean(x)
 latlon_df_clean(testpoints_bad, set_invalid_to_na = F, invalid_msg_table = T)