| Type: | Package |
| Title: | Well-Known Locations in R |
| Version: | 0.2.5 |
| Description: | Makes it easy to find global administrative boundaries from countries to cities using readable, 'chainable' R syntax. Fetches geometries from Overture Maps Foundation data. Ported from https://github.com/wherobots/wkls. |
| License: | Apache License (≥ 2) |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Suggests: | curl, jsonlite, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Imports: | DBI, duckdb, utils |
| NeedsCompilation: | no |
| Packaged: | 2026-01-14 08:04:28 UTC; tedba |
| Author: | Ted Banken [aut, cre] |
| Maintainer: | Ted Banken <tedbanken@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-01-19 18:30:02 UTC |
Dollar operator for wkls_proxy
Description
Provides access to chaining attributes and methods
Usage
## S3 method for class 'wkls_proxy'
x$name
Arguments
x |
A wkls_proxy object |
name |
Name of attribute or method to access |
Value
Depends on usage: a wkls_proxy object for chaining, a function for methods (wkt, wkb, etc.), or a data frame for helper methods (countries, regions, etc.)
Build a query for listing entities with deduplication
Description
Build a query for listing entities with deduplication
Usage
.build_list_query(
country_iso,
region_iso = NULL,
subtype_filter,
distinct_col = "name_primary"
)
Internal function to get geometry
Description
Internal function to get geometry
Usage
.get_geom_expr(chain, expr)
Initialize the wkls table
Description
Initialize the wkls table
Usage
.initialize_table()
Check if a country code represents a dependency
Description
Check if a country code represents a dependency
Usage
.is_dependency(country_iso)
Create a geometry method closure
Description
Create a geometry method closure
Usage
.make_geometry_method(chain, expr_template, ...)
Create a helper method (countries, regions, etc.)
Description
Create a helper method (countries, regions, etc.)
Usage
.make_helper_method(chain, expected_levels, error_msg, query_builder)
Create a wkls proxy object
Description
Create a wkls proxy object
Usage
.make_wkls_proxy(chain = character(0))
Package load hook
Description
Package load hook
Usage
.onLoad(libname, pkgname)
Arguments
libname |
Library name |
pkgname |
Package name |
Internal function to resolve a chain
Description
Internal function to resolve a chain
Usage
.resolve_chain(chain, is_pattern = FALSE)
Extract rows/columns like a data frame
Description
Allows subsetting the resolved data
Usage
## S3 method for class 'wkls_proxy'
x[i, j, drop = TRUE]
Arguments
x |
A wkls_proxy object |
i |
Row indices |
j |
Column indices |
drop |
Whether to drop dimensions |
Value
A subset of the resolved data frame
Double bracket operator for wkls_proxy
Description
Allows dictionary-style access and pattern matching with percent signs
Usage
## S3 method for class 'wkls_proxy'
x[[name]]
Arguments
x |
A wkls_proxy object |
name |
Name to access (supports % for pattern matching) |
Value
A wkls_proxy object for regular lookups, or a data frame when pattern matching is used (names containing %)
Convert wkls_proxy to data frame
Description
Explicitly converts a wkls_proxy to a data frame by resolving the chain
Usage
## S3 method for class 'wkls_proxy'
as.data.frame(x, ...)
Arguments
x |
A wkls_proxy object |
... |
Additional arguments (unused) |
Value
A data frame with columns: id, country, region, subtype, name
Get dimensions
Description
Returns the dimensions (rows and columns) of the resolved data
Usage
## S3 method for class 'wkls_proxy'
dim(x)
Arguments
x |
A wkls_proxy object |
Value
An integer vector of length 2 giving rows and columns, or c(0L, 0L) for empty chains
Check if object is a wkls_proxy
Description
S3 method that identifies wkls_proxy objects as data frames
Usage
is.data.frame.wkls_proxy(x)
Arguments
x |
A wkls_proxy object |
Value
A logical value: always returns TRUE for wkls_proxy objects
Get column names
Description
Returns the column names of the resolved data
Usage
## S3 method for class 'wkls_proxy'
names(x)
Arguments
x |
A wkls_proxy object |
Value
A character vector of column names, typically: "id", "country", "region", "subtype", "name"
Get number of columns
Description
Returns the number of columns in the resolved data
Usage
ncol.wkls_proxy(x)
Arguments
x |
A wkls_proxy object |
Value
An integer representing the number of columns, or 0L for empty chains
Get number of rows
Description
Returns the number of rows in the resolved data
Usage
nrow.wkls_proxy(x)
Arguments
x |
A wkls_proxy object |
Value
An integer representing the number of rows, or 0L for empty chains
Print method for wkls_proxy
Description
Prints the resolved data frame for a wkls_proxy chain
Usage
## S3 method for class 'wkls_proxy'
print(x, ...)
Arguments
x |
A wkls_proxy object |
... |
Additional arguments (unused) |
Value
Invisibly returns the resolved data frame
Well-Known Locations Object
Description
The main entry point for accessing global administrative boundaries. Chain country, region, and city codes to retrieve geographical data.
Usage
wkls
Format
A wkls_proxy object
Examples
# Get country geometry
wkls$us$wkt()
# Get region geometry
wkls$us$ca$geojson()
# Get city geometry
wkls$us$ca$sanfrancisco$wkt()
# List all countries
wkls$countries()
# List regions in a country
wkls$us$regions()