Skip to contents

This function retrieves a GeoServer WFS (Web Feature Service) vector layer as an sf object. It assumes the GeoServer layer is served in GeoJSON format.

Usage

get_geoserver_layer(
  layer_name,
  workspace = "Columbia",
  base_url = "https://geoserver.megaloptera-data.com/geoserver",
  raster = FALSE
)

Arguments

layer_name

Name of the layer (without workspace prefix)

workspace

Workspace name (default: "Columbia")

base_url

Base WFS URL (default: Columbia GeoServer endpoint)

raster

Logical indicating whether to return raster data (TRUE) or vector data (FALSE). Default is FALSE.

Value

An sf object representing the requested vector layer, or NULL with a warning if the request fails.

GeoServer Protocol Comparison

ProtocolFull NamePurposeTypical DataAccess with
WFSWeb Feature ServiceRetrieve vector features + attributesShapefiles, GeoJSONsf::st_read()
WMSWeb Map ServiceDisplay map tiles (no analysis)Rendered image tilesleaflet::addWMSTiles()
WCSWeb Coverage ServiceAccess raster data for analysisGeoTIFF, NetCDF, imageryterra::rast()

Use this function when you need vector data for analysis. For raster datasets (e.g., USDA cropland,lidar), use a WCS endpoint and the terra package.

Examples

if (FALSE) { # \dontrun{
  get_geoserver_layer("all_columbia_huc_12s")
} # }