| Title: | Access and Import WMS and WFS Data from Argentine Organizations |
|---|---|
| Description: | Provides functions to retrieve information from Web Feature Service (WFS) and Web Map Service (WMS) layers from various Argentine organizations and import them into R for further analysis. WFS and WMS are standardized protocols for serving georeferenced map data over the internet. For more information on these services, see <https://www.ogc.org/standard/wfs/> and <https://www.ogc.org/standard/wms/>. |
| Authors: | Thomas Artopoulos [aut, cre] |
| Maintainer: | Thomas Artopoulos <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-05-26 08:20:37 UTC |
| Source: | https://github.com/thomasartopoulos/argentum |
This function downloads WFS layers from specified organizations to a local folder. It can download all layers from an organization or specific layers by name.
argentum_download_layers( organization, output_dir = file.path(tempdir(), "wfs_layers"), layer_names = NULL, format = c("gpkg", "shp", "geojson"), overwrite = FALSE )argentum_download_layers( organization, output_dir = file.path(tempdir(), "wfs_layers"), layer_names = NULL, format = c("gpkg", "shp", "geojson"), overwrite = FALSE )
organization |
A character string specifying the name of the organization |
output_dir |
Path to the directory where files will be saved. Defaults to a temporary directory. |
layer_names |
Optional vector of layer names to download. If NULL, downloads all available layers |
format |
Output format for the files. One of "gpkg" (GeoPackage), "shp" (Shapefile), or "geojson" (GeoJSON) |
overwrite |
Logical; should existing files be overwritten? |
Download WFS Layers to Folder
Invisibly returns a data frame with download results
# Get available organizations orgs <- argentum_list_organizations() if (nrow(orgs) > 0) { argentum_download_layers(orgs$Name[1], output_dir = tempdir()) }# Get available organizations orgs <- argentum_list_organizations() if (nrow(orgs) > 0) { argentum_download_layers(orgs$Name[1], output_dir = tempdir()) }
Get WMS or WFS Capabilities
argentum_get_capabilities(url, max_tries = 3, timeout = 30)argentum_get_capabilities(url, max_tries = 3, timeout = 30)
url |
The full URL of the WMS or WFS service, including all parameters |
max_tries |
The maximum number of attempts to connect |
timeout |
The timeout for each attempt in seconds |
An XML document containing the service capabilities
try({ capabilities <- argentum_get_capabilities("http://example.com/wfs") print(capabilities) })try({ capabilities <- argentum_get_capabilities("http://example.com/wfs") print(capabilities) })
Import WFS Layer
argentum_import_wfs_layer(wfs_url, layer_name)argentum_import_wfs_layer(wfs_url, layer_name)
wfs_url |
The URL of the WFS service |
layer_name |
The name of the layer to import |
An sf object
tryCatch({ sf_layer <- argentum_import_wfs_layer("http://example.com/wfs", "example_layer") print(sf_layer) }, error = function(e) { message("Error occurred: ", e$message) })tryCatch({ sf_layer <- argentum_import_wfs_layer("http://example.com/wfs", "example_layer") print(sf_layer) }, error = function(e) { message("Error occurred: ", e$message) })
This function provides an interactive interface to download WFS layers. Users can select an organization, choose specific layers or download all, and specify the output format and directory.
argentum_interactive_download(output_dir = NULL)argentum_interactive_download(output_dir = NULL)
output_dir |
Optional; Path to the directory where files will be saved. If NULL, user will be prompted |
Download WFS Layers Interactively
Invisibly returns a data frame with download results
# Try to download interactively tryCatch({ results <- argentum_interactive_download() }, error = function(e) { message("Error: ", e$message) })# Try to download interactively tryCatch({ results <- argentum_interactive_download() }, error = function(e) { message("Error: ", e$message) })
Import WFS Layer Interactively
argentum_interactive_import()argentum_interactive_import()
An sf object
sf_layer <- argentum_interactive_import()sf_layer <- argentum_interactive_import()
This function retrieves and lists the available layers for a specified organization.
argentum_list_layers(organization)argentum_list_layers(organization)
organization |
A character string specifying the name of the organization |
A data frame containing layer information with columns 'Name' and 'Title'
# This example uses a mock organization name. # In a real scenario, use an actual organization name from argentum_list_organizations() tryCatch({ orgs <- argentum_list_organizations() if(nrow(orgs) > 0) { layers <- argentum_list_layers(orgs$Name[1]) print(layers) } else { message("No organizations found.") } }, error = function(e) { message("Error occurred: ", e$message) })# This example uses a mock organization name. # In a real scenario, use an actual organization name from argentum_list_organizations() tryCatch({ orgs <- argentum_list_organizations() if(nrow(orgs) > 0) { layers <- argentum_list_layers(orgs$Name[1]) print(layers) } else { message("No organizations found.") } }, error = function(e) { message("Error occurred: ", e$message) })
List Organizations with WMS and WFS Services
argentum_list_organizations()argentum_list_organizations()
A data frame containing organization information including WMS and WFS URLs
Select Organization
argentum_select_organization(search = NULL, interactive_select = interactive())argentum_select_organization(search = NULL, interactive_select = interactive())
search |
An optional search term to filter organizations |
interactive_select |
Logical; whether to run in interactive mode. Defaults to |
A data frame containing the selected organization's information, or NULL if no selection is made
# List available organizations orgs <- argentum_list_organizations() print(orgs) # Select organization non-interactively selected_org <- argentum_select_organization(interactive_select = FALSE) print(selected_org) if(interactive()){ # Select an organization interactively selected_org <- argentum_select_organization() # Select an organization with a search term selected_org <- argentum_select_organization("Example") }# List available organizations orgs <- argentum_list_organizations() print(orgs) # Select organization non-interactively selected_org <- argentum_select_organization(interactive_select = FALSE) print(selected_org) if(interactive()){ # Select an organization interactively selected_org <- argentum_select_organization() # Select an organization with a search term selected_org <- argentum_select_organization("Example") }