Skip to contents

Test validity of a geocode or ensure that a geocode is valid.

Usage

validate_geocode(geocode)

is_valid_geocode(geocode)

length_geocode(geocode)

na_geocode()

Arguments

geocode

data.frame with geocode data in columns "lat", "lon", and possibly also "address".

Value

A valid geocode stored in a tibble.

FALSE for invalid, TRUE for valid.

FALSE for invalid, number of rows for valid.

A geo_code tibble with all fields set to suitable NAs.

Details

validate_geocode Converts to tibble, checks data bounds, converts address to character if it is not already a character vector, or add character NAs if the address column is missing.

is_valid_geocode Checks if a geocode is valid, returning 0L if not, and the number of row otherwise.

Examples


validate_geocode(NA)
#> # A tibble: 1 × 3
#>     lon   lat address
#>   <dbl> <dbl> <chr>  
#> 1    NA    NA NA     
validate_geocode(data.frame(lon = -25, lat = 66))
#> # A tibble: 1 × 3
#>     lon   lat address
#>   <dbl> <dbl> <chr>  
#> 1   -25    66 NA     

is_valid_geocode(NA)
#> [1] FALSE
is_valid_geocode(1L)
#> [1] FALSE
is_valid_geocode(data.frame(lon = -25, lat = 66))
#> [1] TRUE

na_geocode()
#> # A tibble: 1 × 3
#>     lon   lat address
#>   <dbl> <dbl> <chr>  
#> 1    NA    NA NA