Title: | Access the Felt API |
---|---|
Description: | Upload, download, and edit internet maps with the Felt API (<https://feltmaps.notion.site/Felt-Public-API-reference-c01e0e6b0d954a678c608131b894e8e1>). Allows users to create new maps, edit existing maps, and extract data. Provides tools for working with layers, which represent geographic data, and elements, which are interactive annotations. Spatial data accessed from the API is transformed to work with 'sf'. |
Authors: | Christopher T. Kenny [aut, cre] |
Maintainer: | Christopher T. Kenny <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-09 02:52:04 UTC |
Source: | https://github.com/christopherkenny/feltr |
Add layer to library
felt_add_library_layer(map_id, layer_id, name = NULL, clean = TRUE)
felt_add_library_layer(map_id, layer_id, name = NULL, clean = TRUE)
map_id |
character, map identifier from url, from |
layer_id |
character, layer identifier from url, from |
name |
character, name to save the layer under. Optional. |
clean |
logical, whether to turn the API response into a tibble::tibble |
a tibble::tibble if clean = TRUE
, otherwise a list
felt_add_library_layer(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_id = '4Lc7RaEyRP2LfARGmR6e4C', name = paste0('Test layer ', Sys.time()))
felt_add_library_layer(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_id = '4Lc7RaEyRP2LfARGmR6e4C', name = paste0('Test layer ', Sys.time()))
Add layer group to library
felt_add_library_layer_group(map_id, layer_group_id, name = NULL, clean = TRUE)
felt_add_library_layer_group(map_id, layer_group_id, name = NULL, clean = TRUE)
map_id |
character, map identifier from url, from |
layer_group_id |
character, layer group identifier from url, from |
name |
character, name to save the layer group under. Optional. |
clean |
logical, whether to turn the API response into a tibble::tibble |
a tibble::tibble if clean = TRUE
, otherwise a list
felt_add_library_layer_group(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_group_id = 'rHxyTef7S9CO8W7n1PvBVwC', name = paste0('Test layer group ', Sys.time()))
felt_add_library_layer_group(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_group_id = 'rHxyTef7S9CO8W7n1PvBVwC', name = paste0('Test layer group ', Sys.time()))
Add Elements to Existing Map
felt_add_map_elements(map_id, elements, clean = TRUE)
felt_add_map_elements(map_id, elements, clean = TRUE)
map_id |
character, map identifier from url, from |
elements |
a sf::sf object or a path to a geojson file |
clean |
logical, whether to turn the API response into a tibble::tibble |
a tibble::tibble with the elements added
elem <- felt_add_map_elements(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', elements = fs::path_package('feltr', 'bbox.geojson')) elem # and delete layer felt_delete_map_elements(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', element_id = elem$felt_id)
elem <- felt_add_map_elements(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', elements = fs::path_package('feltr', 'bbox.geojson')) elem # and delete layer felt_delete_map_elements(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', element_id = elem$felt_id)
Add Layers to Existing Map
felt_add_map_layers( map_id, name = NULL, file_names = NULL, lat = NULL, lng = NULL, zoom = NULL, clean = TRUE )
felt_add_map_layers( map_id, name = NULL, file_names = NULL, lat = NULL, lng = NULL, zoom = NULL, clean = TRUE )
map_id |
character, map identifier from url, from |
name |
Name of the layer. Required. |
file_names |
Files to include. Required. |
lat |
For images, the latitude of the center of the image. Optional. |
lng |
For images, the longitude of the center of the image. Optional. |
zoom |
For images, the zoom level of the image. Optional. |
clean |
logical, whether to turn the API response into a tibble::tibble |
status of the upload
layer <- felt_add_map_layers(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', file_names = fs::path_package('feltr', 'towns.geojson'), name = 'Towns test') layer
layer <- felt_add_map_layers(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', file_names = fs::path_package('feltr', 'towns.geojson'), name = 'Towns test') layer
See Felt "Upload Anything" documentation for detailed examples of potential URLs.
felt_add_map_layers_url(map_id, url, name = NULL, clean = TRUE)
felt_add_map_layers_url(map_id, url, name = NULL, clean = TRUE)
map_id |
character, map identifier from url, from |
url |
Link to layer to include. Required |
name |
Name of the layer. Required. |
clean |
logical, whether to turn the API response into a tibble::tibble |
a tibble::tibble for the created layer
# split the URL for length reasons url <- paste0( 'https://www.rocklandgis.com/portal/sharing/rest/', 'content/items/73fc78cb0fb04580b4788937fe5ee697/data' ) layer <- felt_add_map_layers_url( map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', url = url, name = 'URL Parks test') layer # and delete the new layer felt_delete_map_layer(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_id = layer$layer_id)
# split the URL for length reasons url <- paste0( 'https://www.rocklandgis.com/portal/sharing/rest/', 'content/items/73fc78cb0fb04580b4788937fe5ee697/data' ) layer <- felt_add_map_layers_url( map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', url = url, name = 'URL Parks test') layer # and delete the new layer felt_delete_map_layer(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_id = layer$layer_id)
Create a new map
felt_create_map( title = NULL, basemap = NULL, layer_urls = NULL, lat = NULL, lon = NULL, zoom = NULL, description = NULL, public_access = NULL, clean = TRUE )
felt_create_map( title = NULL, basemap = NULL, layer_urls = NULL, lat = NULL, lon = NULL, zoom = NULL, description = NULL, public_access = NULL, clean = TRUE )
title |
Title to use for the map. Defaults to |
basemap |
Basemap for the new map. Defaults to |
layer_urls |
vector of URLs to generate layers in map. Defaults to |
lat |
latitude to center the map. Defaults to |
lon |
longitude to center the map. Defaults to |
zoom |
zoom level to initialize the map with. Defaults to |
description |
Description for the map legend. Defaults to |
public_access |
Degree of public acess. Defaults to |
clean |
logical, whether to turn the API response into a tibble::tibble |
a tibble::tibble for the new map
map <- felt_create_map(title = 'feltr example') map # and delete it again felt_delete_map(map_id = map$id)
map <- felt_create_map(title = 'feltr example') map # and delete it again felt_delete_map(map_id = map$id)
Delete an existing map
felt_delete_map(map_id)
felt_delete_map(map_id)
map_id |
character, map identifier from url, from |
response code
map <- felt_create_map(title = 'feltr example') felt_delete_map(map_id = map$id)
map <- felt_create_map(title = 'feltr example') felt_delete_map(map_id = map$id)
Delete an existing element
felt_delete_map_elements(map_id, element_id)
felt_delete_map_elements(map_id, element_id)
map_id |
character, map identifier from url, from |
element_id |
element identifier, as returned by |
response code
elem <- felt_add_map_elements(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', elements = fs::path_package('feltr', 'bbox.geojson')) elem # and delete layer felt_delete_map_elements(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', element_id = elem$felt_id)
elem <- felt_add_map_elements(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', elements = fs::path_package('feltr', 'bbox.geojson')) elem # and delete layer felt_delete_map_elements(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', element_id = elem$felt_id)
Delete Layer from an Existing Map
felt_delete_map_layer(map_id, layer_id, clean = TRUE)
felt_delete_map_layer(map_id, layer_id, clean = TRUE)
map_id |
character, map identifier from url, from |
layer_id |
character, layer identifier from url, from |
clean |
logical, whether to turn the API response into a tibble::tibble |
response code
# split the URL for length reasons url <- paste0( 'https://www.rocklandgis.com/portal/sharing/rest/', 'content/items/73fc78cb0fb04580b4788937fe5ee697/data' ) layer <- felt_add_map_layers_url( map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', url = url, name = 'URL Parks test') layer # and delete the new layer felt_delete_map_layer(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_id = layer$layer_id)
# split the URL for length reasons url <- paste0( 'https://www.rocklandgis.com/portal/sharing/rest/', 'content/items/73fc78cb0fb04580b4788937fe5ee697/data' ) layer <- felt_add_map_layers_url( map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', url = url, name = 'URL Parks test') layer # and delete the new layer felt_delete_map_layer(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_id = layer$layer_id)
Export Comments on an Existing Map
felt_get_comments(map_id, clean = TRUE)
felt_get_comments(map_id, clean = TRUE)
map_id |
character, map identifier from url, from |
clean |
logical, whether to turn the API response into a tibble::tibble |
a tibble::tibble for the map
felt_get_comments(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA')
felt_get_comments(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA')
List all layers in your workspace library
felt_get_library(source = "workspace", clean = TRUE)
felt_get_library(source = "workspace", clean = TRUE)
source |
character, source of the layers, one of |
clean |
logical, whether to turn the API response into a tibble::tibble |
a tibble::tibble if clean = TRUE
, otherwise a list
felt_get_library()
felt_get_library()
felt_get_map()
returns identifying information for the map
felt_get_map_layers()
returns information about each layer in the map
felt_get_map_elements()
returns the shapes for each layer in the map
felt_get_map(map_id, clean = TRUE) felt_get_map_layers(map_id, clean = TRUE) felt_get_map_layer(map_id, layer_id, clean = TRUE)
felt_get_map(map_id, clean = TRUE) felt_get_map_layers(map_id, clean = TRUE) felt_get_map_layer(map_id, layer_id, clean = TRUE)
map_id |
character, map identifier from url, from |
clean |
logical, whether to turn the API response into a tibble::tibble |
layer_id |
character, layer identifier from url, from |
a tibble::tibble for the map, if clean = TRUE
, otherwise a list
felt_get_map('Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA') felt_get_map_layers('Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA') # slower, as it has to build the shapes from the API result felt_get_map_elements('Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA')
felt_get_map('Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA') felt_get_map_layers('Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA') # slower, as it has to build the shapes from the API result felt_get_map_elements('Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA')
Get Map Elements from Map ID
felt_get_map_elements(map_id, clean = TRUE) felt_get_map_element_groups(map_id, clean = TRUE) felt_get_map_elements_in_group(map_id, group_id, clean = TRUE)
felt_get_map_elements(map_id, clean = TRUE) felt_get_map_element_groups(map_id, clean = TRUE) felt_get_map_elements_in_group(map_id, group_id, clean = TRUE)
map_id |
character, map identifier from url, from |
clean |
logical, whether to turn the API response into a tibble::tibble |
group_id |
group identifier, as returned by |
a tibble::tibble for the map
felt_get_map_elements(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA') felt_get_map_element_groups('TBI8sDkmQjuK2GX9CSiHiUA') felt_get_map_elements_in_group('TBI8sDkmQjuK2GX9CSiHiUA', '3Wl5s2AqRmiYgO9CrBFxO3D')
felt_get_map_elements(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA') felt_get_map_element_groups('TBI8sDkmQjuK2GX9CSiHiUA') felt_get_map_elements_in_group('TBI8sDkmQjuK2GX9CSiHiUA', '3Wl5s2AqRmiYgO9CrBFxO3D')
Get information for a layer group
felt_get_map_layer_group(map_id, layer_group_id, clean = TRUE)
felt_get_map_layer_group(map_id, layer_group_id, clean = TRUE)
map_id |
character, map identifier from url, from |
layer_group_id |
character, layer group identifier from url, from |
clean |
logical, whether to turn the API response into a tibble::tibble |
a tibble::tibble for the layer group, if clean = TRUE
, otherwise a list
felt_get_map_layer_group( map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', layer_group_id = 'rHxyTef7S9CO8W7n1PvBVwC' )
felt_get_map_layer_group( map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', layer_group_id = 'rHxyTef7S9CO8W7n1PvBVwC' )
Obtain information about the user
felt_get_user(clean = TRUE)
felt_get_user(clean = TRUE)
clean |
logical, whether to turn the API response into a tibble::tibble |
a tibble::tibble of information about the user
felt_get_user()
felt_get_user()
For details on the Felt Style Language, see https://felt.com/blog/felt-style-language.
felt_patch_style(map_id, layer_id, fsl, clean = TRUE)
felt_patch_style(map_id, layer_id, fsl, clean = TRUE)
map_id |
character, map identifier from url, from |
layer_id |
character, layer identifier from url, from |
fsl |
A list indicating the Felt style language to update the layer to. It must be valid FSL. |
clean |
logical, whether to turn the API response into a tibble::tibble |
response data
# URL Parks layer # read as a list layer <- felt_get_map_layer(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_id = 'eufG5hWKRRSURHE8YcGGXA', clean = FALSE) # use the existing style for easiest modification style <- layer$style style$label$minZoom <- round(runif(1, 0, 23)) felt_patch_style(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', layer_id = 'eufG5hWKRRSURHE8YcGGXA', fsl = style)
# URL Parks layer # read as a list layer <- felt_get_map_layer(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_id = 'eufG5hWKRRSURHE8YcGGXA', clean = FALSE) # use the existing style for easiest modification style <- layer$style style$label$minZoom <- round(runif(1, 0, 23)) felt_patch_style(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', layer_id = 'eufG5hWKRRSURHE8YcGGXA', fsl = style)
Refresh an existing layer
felt_refresh_layer(map_id, layer_id, file_names, clean = TRUE)
felt_refresh_layer(map_id, layer_id, file_names, clean = TRUE)
map_id |
character, map identifier from url, from |
layer_id |
character, layer identifier from url, from |
file_names |
file names to upload if the original layer was created with a file upload |
clean |
logical, whether to turn the API response into a tibble::tibble |
a tibble::tibble with upload information
felt_refresh_layer(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', layer_id = 'rCfurZSFShycXHCBw69CdKB', file_names = fs::path_package('feltr', 'towns.geojson')) felt_refresh_layer(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', layer_id = 'eufG5hWKRRSURHE8YcGGXA')
felt_refresh_layer(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', layer_id = 'rCfurZSFShycXHCBw69CdKB', file_names = fs::path_package('feltr', 'towns.geojson')) felt_refresh_layer(map_id = 'Rockland-2024-Districts-TBI8sDkmQjuK2GX9CSiHiUA', layer_id = 'eufG5hWKRRSURHE8YcGGXA')
Allows for updates to the name, ordering key, and subtitle.
felt_update_layer_details( map_id, layer_id, layer_group_id = NULL, name = NULL, ordering_key = NULL, subtitle = NULL, clean = TRUE )
felt_update_layer_details( map_id, layer_id, layer_group_id = NULL, name = NULL, ordering_key = NULL, subtitle = NULL, clean = TRUE )
map_id |
character, map identifier from url, from |
layer_id |
character, layer identifier from url, from |
layer_group_id |
character, layer group identifier from url, from |
name |
Name of the layer. Defaults to |
ordering_key |
Integer to order layers. Defaults to |
subtitle |
Subtitle for the layer. Defaults to |
clean |
logical, whether to turn the API response into a tibble::tibble |
response data
felt_update_layer_details(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_id = 'eufG5hWKRRSURHE8YcGGXA', subtitle = paste0('tested ', Sys.Date()))
felt_update_layer_details(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_id = 'eufG5hWKRRSURHE8YcGGXA', subtitle = paste0('tested ', Sys.Date()))
Allows for updates to the name, ordering key, and subtitle.
felt_update_layer_group_details( map_id, layer_group_id, name = NULL, ordering_key = NULL, subtitle = NULL, clean = TRUE )
felt_update_layer_group_details( map_id, layer_group_id, name = NULL, ordering_key = NULL, subtitle = NULL, clean = TRUE )
map_id |
character, map identifier from url, from |
layer_group_id |
character, layer group identifier from url, from |
name |
Name of the layer group. Required. |
ordering_key |
Integer to order by. Defaults to |
subtitle |
Subtitle for the layer group. Defaults to |
clean |
logical, whether to turn the API response into a tibble::tibble |
response data
felt_update_layer_group_details(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_group_id = 'rHxyTef7S9CO8W7n1PvBVwC', name = 'Polling Sites 2020', subtitle = paste0('tested ', Sys.Date()))
felt_update_layer_group_details(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', layer_group_id = 'rHxyTef7S9CO8W7n1PvBVwC', name = 'Polling Sites 2020', subtitle = paste0('tested ', Sys.Date()))
Allows for updates to the title, description, and level of public access.
felt_update_map_details( map_id, title = NULL, description = NULL, public_access = NULL, clean = TRUE )
felt_update_map_details( map_id, title = NULL, description = NULL, public_access = NULL, clean = TRUE )
map_id |
character, map identifier from url, from |
title |
Title to use for the map. Defaults to |
description |
Description for the map legend. Defaults to |
public_access |
Degree of public acess. Defaults to |
clean |
logical, whether to turn the API response into a tibble::tibble |
response data
felt_update_map_details(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', title = paste0('Rockland 2024 Districts, tested ', Sys.Date()))
felt_update_map_details(map_id = 'TBI8sDkmQjuK2GX9CSiHiUA', title = paste0('Rockland 2024 Districts, tested ', Sys.Date()))
Check or Get Felt API Key
has_felt_key() get_felt_key() felt_get_key() felt_has_key()
has_felt_key() get_felt_key() felt_get_key() felt_has_key()
logical if has
, key if get
has_felt_key()
has_felt_key()
Adds Felt API key to .Renviron.
set_felt_key(key, overwrite = FALSE, install = FALSE, r_env = NULL) felt_set_key(key, overwrite = FALSE, install = FALSE, r_env = NULL)
set_felt_key(key, overwrite = FALSE, install = FALSE, r_env = NULL) felt_set_key(key, overwrite = FALSE, install = FALSE, r_env = NULL)
key |
Character. API key to add to add. |
overwrite |
Defaults to FALSE. Boolean. Should existing |
install |
Defaults to FALSE. Boolean. Should this be added to an environment file, |
r_env |
Path to install to if |
key, invisibly
example_env <- tempfile(fileext = '.Renviron') set_felt_key('1234', r_env = example_env) # r_env should likely be: file.path(Sys.getenv('HOME'), '.Renviron')
example_env <- tempfile(fileext = '.Renviron') set_felt_key('1234', r_env = example_env) # r_env should likely be: file.path(Sys.getenv('HOME'), '.Renviron')