An R6 object that holds your connection settings and gives you one method per
public route. Create it with close_client() rather than calling $new().
Results come back per the output field: an sf object where geometry
applies, a data frame otherwise, or a close_reply when output is 'raw'.
Public fields
output(
character(1))
How results come back:'spatial','tabular', or'raw'. Change it any time, or override it per call with the method'soutputargument.
Methods
CloseClient$new()
Create a client. Prefer close_client().
Usage
CloseClient$new(
api_key = NULL,
base_url = DEFAULT_BASE_URL,
timeout = 30,
output = "spatial"
)CloseClient$last_updated()
Publication time of the newest data (free). Always a raw reply.
Returns
A close_reply.
CloseClient$modes()
Travel modes and their numeric ids (free).
Returns
A data frame, or a close_reply when output is 'raw'.
CloseClient$destination_types()
Destination-type taxonomy (free). Use it to look up the numeric
type ids the data routes filter on; a parent type expands to its
leaf_ids.
Returns
A data frame, or a close_reply when output is 'raw'.
CloseClient$vintage()
Active version of each dataset component (free).
Returns
A data frame, or a close_reply when output is 'raw'.
CloseClient$places()
Look up a city or town by name (free). Each match carries its census place GEOID and centre point.
Arguments
qName to search for, such as "Providence".
limitMost matches to return (1 to 20).
outputOverride the client's output mode for this call.
Returns
An sf of points (a data frame in tabular mode, a
close_reply when output is 'raw').
CloseClient$block_summary()
Fastest travel time from a census block to each destination category, by mode. Pass a vector of GEOIDs to query many blocks in one call (one request, one rate-limit tick).
Usage
CloseClient$block_summary(
geoid,
mode = NULL,
type = NULL,
if_none_match = NULL,
output = NULL
)Arguments
geoidA 15-digit census block GEOID, or a vector of them for a single multi-origin call. Every result row carries its origin
geoid; per-originerrors/truncated/truncated_reasonride on the frame's attributes.modeTravel mode(s) to keep: "walk", "bike", "transit".
typeDestination type id(s) to keep.
if_none_matchAn ETag from an earlier reply, to revalidate for free (single-block form only).
outputOverride the client's output mode for this call.
Returns
A data frame with a broadcast geoid column, or a close_reply
when output is 'raw'.
CloseClient$block_pois()
Nearby points of interest and their travel time from a block, one row per (POI, mode). Reads every page by default. Pass a vector of GEOIDs to query many blocks in one call (one request, one rate-limit tick; the multi-origin form is not paginated).
Usage
CloseClient$block_pois(
geoid,
mode = NULL,
type = NULL,
dest_id = NULL,
max_minutes = NULL,
limit = NULL,
cursor = NULL,
paginate = TRUE,
output = NULL
)Arguments
geoidA 15-digit census block GEOID, or a vector of them for a single multi-origin call. Every row carries its origin
geoid; per-originerrors/truncatedride on the frame's attributes.modeTravel mode(s) to keep.
typeDestination type id(s) to keep.
dest_idSpecific destination id(s) to keep.
max_minutesUpper bound on travel time (up to 30).
limitRows per page (up to 1000; single-block form only).
cursorPage cursor from a previous reply's
next_cursor; supplying one fetches only that page.paginateFollow
next_cursorand return every page (the default); setFALSEfor the first page only.outputOverride the client's output mode for this call.
Returns
An sf of points (a data frame in tabular mode, a
close_reply when output is 'raw').
CloseClient$point_summary()
Like $block_summary(), but from the block containing a
lat/lon point. The resolved block is echoed as resolved_block and
broadcast to a geoid column. Pass equal-length lat / lon vectors to
query many points in one call (one request, one rate-limit tick).
Usage
CloseClient$point_summary(
lat,
lon,
mode = NULL,
type = NULL,
if_none_match = NULL,
output = NULL
)Arguments
latLatitude, or a vector of latitudes for a multi-origin call.
lonLongitude, or a matching vector of longitudes. In the multi-origin form each row carries its
origin_lat/origin_lon, and resolved blocks /errors/truncatedride on the frame's attributes.modeTravel mode(s) to keep.
typeDestination type id(s) to keep.
if_none_matchAn ETag to revalidate for free (single-point form only).
outputOverride the client's output mode for this call.
Returns
A data frame, or a close_reply when output is 'raw'.
CloseClient$point_pois()
Like $block_pois(), but from the block containing a lat/lon
point. Reads every page by default. Pass equal-length lat / lon
vectors to query many points in one call (one request, one rate-limit
tick; the multi-origin form is not paginated).
Usage
CloseClient$point_pois(
lat,
lon,
mode = NULL,
type = NULL,
dest_id = NULL,
max_minutes = NULL,
limit = NULL,
cursor = NULL,
paginate = TRUE,
output = NULL
)Arguments
latLatitude, or a vector of latitudes for a multi-origin call.
lonLongitude, or a matching vector of longitudes. In the multi-origin form each row carries its
origin_lat/origin_lon.modeTravel mode(s) to keep.
typeDestination type id(s) to keep.
dest_idSpecific destination id(s) to keep.
max_minutesUpper bound on travel time (up to 30).
limitRows per page (up to 1000; single-point form only).
cursorPage cursor; supplying one fetches only that page.
paginateFollow
next_cursorand return every page (the default); setFALSEfor the first page only.outputOverride the client's output mode for this call.
Returns
An sf of points (a data frame in tabular mode, a
close_reply when output is 'raw').
CloseClient$pois_search()
Search points of interest by bounding box, or by a circle
(lat + lon + radius_m). Reads every page by default.
Usage
CloseClient$pois_search(
lat = NULL,
lon = NULL,
radius_m = NULL,
bbox = NULL,
type = NULL,
q = NULL,
limit = NULL,
cursor = NULL,
paginate = TRUE,
output = NULL
)Arguments
lat, lonCircle centre.
radius_mCircle radius, in metres (up to 50000).
bboxBounding box, "min_lon,min_lat,max_lon,max_lat".
typeDestination type id(s) to keep.
qName text to match.
limitRows per page (up to 1000).
cursorPage cursor; supplying one fetches only that page.
paginateFollow
next_cursorand return every page (the default); setFALSEfor the first page only.outputOverride the client's output mode for this call.
Returns
An sf of points (a data frame in tabular mode, a
close_reply when output is 'raw').
CloseClient$poi()
Details for one point of interest.
Arguments
dest_idDestination id.
if_none_matchAn ETag to revalidate for free.
outputOverride the client's output mode for this call.
Returns
An sf of one point (a data frame in tabular mode, a
close_reply when output is 'raw').
CloseClient$poi_catchment()
Every census block that can reach a point of interest, one row per (block, mode). Reads every page by default. Pass a vector of dest_ids to query many POIs in one call (one request, one rate-limit tick; the multi-origin form is not paginated).
Usage
CloseClient$poi_catchment(
dest_id,
mode = NULL,
block = NULL,
max_minutes = NULL,
limit = NULL,
cursor = NULL,
paginate = TRUE,
output = NULL
)Arguments
dest_idA destination id, or a vector of them for a single multi-origin call. Every row carries its origin
dest_id; per-POIerrors/truncatedride on the frame's attributes.modeTravel mode(s) to keep.
blockSpecific block id(s) to keep.
max_minutesUpper bound on travel time (up to 30).
limitRows per page (up to 1000; single-POI form only).
cursorPage cursor; supplying one fetches only that page.
paginateFollow
next_cursorand return every page (the default); setFALSEfor the first page only.outputOverride the client's output mode for this call.
Returns
An sf of block polygons (a data frame in tabular mode, a
close_reply when output is 'raw').
CloseClient$blocks_query()
Blocks inside a GeoJSON polygon, or a circle (center +
radius_m), one row per (block, category, mode). Rows carry the numeric
mode_id (join $modes() to label it). Reads every page by default.
Usage
CloseClient$blocks_query(
polygon = NULL,
center = NULL,
radius_m = NULL,
type = NULL,
mode = NULL,
include_population = NULL,
limit = NULL,
cursor = NULL,
paginate = TRUE,
output = NULL
)Arguments
polygonA GeoJSON polygon or multipolygon (a list).
centerA circle centre,
list(lon =, lat =).radius_mCircle radius, in metres (up to 28000).
typeDestination type id(s) to keep.
modeTravel mode(s) to keep.
include_populationAdd each block's population to its rows.
limitRows per page (up to 1000).
cursorPage cursor; supplying one fetches only that page.
paginateFollow
next_cursorand return every page (the default); setFALSEfor the first page only.outputOverride the client's output mode for this call.
Returns
An sf of block polygons (a data frame in tabular mode, a
close_reply when output is 'raw').
CloseClient$place_blocks()
Per-block travel times for every block in a place (a city or
town), by place GEOID. Rows carry the numeric mode_id (join $modes()
to label it). Reads every page by default.
Usage
CloseClient$place_blocks(
geoid,
mode = NULL,
type = NULL,
include_population = NULL,
limit = NULL,
cursor = NULL,
paginate = TRUE,
output = NULL
)Arguments
geoidCensus place GEOID.
modeTravel mode(s) to keep.
typeDestination type id(s) to keep.
include_populationAdd each block's population to its rows.
limitRows per page (up to 1000).
cursorPage cursor; supplying one fetches only that page.
paginateFollow
next_cursorand return every page (the default); setFALSEfor the first page only.outputOverride the client's output mode for this call.
Returns
An sf of block polygons (a data frame in tabular mode, a
close_reply when output is 'raw').
CloseClient$place_pois()
Every point of interest within a census place (a city or
town), by place GEOID. The place analog of $pois_search(); pass
type to get, e.g., all supermarkets in a city. Spatial only, no
travel times. Reads every page by default.
Usage
CloseClient$place_pois(
geoid,
type = NULL,
q = NULL,
limit = NULL,
cursor = NULL,
paginate = TRUE,
output = NULL
)Arguments
geoidCensus place GEOID.
typeDestination type id(s) to keep.
qName substring to match.
limitRows per page (up to 1000).
cursorPage cursor; supplying one fetches only that page.
paginateFollow
next_cursorand return every page (the default); setFALSEfor the first page only.outputOverride the client's output mode for this call.
Returns
An sf of points (a data frame in tabular mode, a
close_reply when output is 'raw').
CloseClient$place_boundary()
The boundary polygon of a census place, as a one-row
sf, handy as a boundary layer for close_map() when mapping
a city's blocks or POIs. Free (no API key).
Returns
A one-row sf polygon (a close_reply when output is
'raw').
CloseClient$isochrone()
Travel-time contours from a block or a lat/lon point. Give
minutes for one threshold, or contours for up to four.
Usage
CloseClient$isochrone(
block = NULL,
lon = NULL,
lat = NULL,
mode = NULL,
direction = NULL,
minutes = NULL,
contours = NULL,
format = NULL,
v = NULL,
if_none_match = NULL,
output = NULL
)Arguments
blockOrigin block GEOID (or give
lon+lat).lon, latOrigin point, instead of
block.mode"walk", "bike", or "transit".
direction"to" (blocks that can reach the origin) or "from".
minutesA single threshold (1 to 60).
contoursUp to four ascending levels, instead of
minutes.format"geojson" (polygons) or "blocks" (a block list).
vOptional cache-buster, echoed back.
if_none_matchAn ETag to revalidate for free.
outputOverride the client's output mode for this call.
Returns
An sf (contour polygons for geojson, block polygons for
blocks), a data frame in tabular mode, or a close_reply when output
is 'raw'.
CloseClient$isochrone_meta()
Isochrone version, directions, modes, and assumptions (free). Always a raw close_reply.
Returns
A close_reply.
CloseClient$records()
Read every record from a paginated method, following the cursor to the last page. The paginated methods now read every page by default, so this is rarely needed; it remains for explicit control and back-compat.
Arguments
endpointName of a paginated method, such as "pois_search".
...Arguments passed on to that method.
outputOverride the client's output mode for this call.
Returns
A data frame (an sf in spatial mode), or a list of records
when output is 'raw'.
