knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
WFS (Web Feature Service) and WMS (Web Map Service) are standardized protocols for serving georeferenced map data over the internet:
When you use Argentum to import WFS layers, you're getting actual vector data that you can analyze and manipulate in R:
library(Argentum) library(sf) # Get organization data org <- argentum_select_organization(search = "Buenos Aires") # List available layers layers <- argentum_list_layers(org$Name) # Import a specific layer sf_layer <- argentum_import_wfs_layer(org$WFS_URL, layers$Name[1]) # Now you can work with the data using sf functions st_crs(sf_layer) # Check the coordinate reference system plot(sf_layer) # Basic plot of the geometry
Before importing data, you can check what capabilities a service offers:
# Get capabilities document capabilities <- argentum_get_capabilities(org$WFS_URL) # The capabilities document contains information about: # - Available layers # - Supported operations # - Coordinate reference systems # - Output formats
Always implement proper error handling:
tryCatch({ # Attempt to import data sf_layer <- argentum_import_wfs_layer(org$WFS_URL, layers$Name[1]) }, error = function(e) { # Handle any errors that occur message("Error importing layer: ", e$message) })
When working with WFS services:
# Use appropriate timeout values for large datasets capabilities <- argentum_get_capabilities( url = org$WFS_URL, timeout = 60 # Increase timeout for slow connections )
After importing WFS data:
library(sf) library(dplyr) # Check the data structure str(sf_layer) # Basic statistics summary(sf_layer) # Spatial operations sf_layer_transformed <- st_transform(sf_layer, 4326) # Calculate areas if working with polygons if (all(st_geometry_type(sf_layer) %in% c("POLYGON", "MULTIPOLYGON"))) { sf_layer$area <- st_area(sf_layer) }
While Argentum provides high-level functions, you can also work with WFS services directly:
# Example of constructing a custom WFS URL base_url <- org$WFS_URL query_params <- list( service = "WFS", version = "1.1.0", request = "GetFeature", typeName = layers$Name[1], outputFormat = "application/json" ) # Build the URL query_url <- httr::modify_url( url = base_url, query = query_params )
Common issues and solutions:
Verify service availability
Invalid Layer Names
argentum_list_layers()
to get exact layer namesVerify layer still exists in service
Data Format Issues
Planned features for future versions:
sessionInfo()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.