Skip to contents

Guess which columns have lat and lon based on aliases like latitude, FacLat, etc.

Usage

latlon_infer(mycolnames)

Arguments

mycolnames

e.g., colnames(x) where x is a data.frame from read.csv

Value

returns all of mycolnames except replacing the best candidates with lat and lon

See also

latlon_df_clean() latlon_is.valid() latlon_as.numeric()fixnames_aliases() fixcolnames_infer()

Examples

  latlon_infer(c('trilat', 'belong', 'belong')) # warns if no alias found, 
#> Error in latlon_infer(c("trilat", "belong", "belong")): could not find function "latlon_infer"
    #  but doesnt warn of dupes in other terms, just preferred term.
  latlon_infer(c('a', 'LONG', 'Longitude', 'lat')) # only the best alias is converted/used
#> Error in latlon_infer(c("a", "LONG", "Longitude", "lat")): could not find function "latlon_infer"
  latlon_infer(c('a', 'LONGITUDE', 'Long', 'Lat')) # only the best alias is converted/used
#> Error in latlon_infer(c("a", "LONGITUDE", "Long", "Lat")): could not find function "latlon_infer"
  latlon_infer(c('a', 'longing', 'Lat', 'lat', 'LAT')) # case variants of preferred are 
#> Error in latlon_infer(c("a", "longing", "Lat", "lat", "LAT")): could not find function "latlon_infer"
      # left alone only if lowercase one is found
  latlon_infer(c('LONG', 'long', 'lat')) # case variants of a single alias are 
#> Error in latlon_infer(c("LONG", "long", "lat")): could not find function "latlon_infer"
      # converted to preferred word (if pref not found), creating dupes!  warn!
  latlon_infer(c('LONG', 'LONG')) # dupes of an alias are renamed and still are dupes! warn!
#> Error in latlon_infer(c("LONG", "LONG")): could not find function "latlon_infer"
  latlon_infer(c('lat', 'lat', 'Lon')) # dupes left as dupes but warn!
#> Error in latlon_infer(c("lat", "lat", "Lon")): could not find function "latlon_infer"