wdnr.gis is a package for pulling data from the Wisconsin Department of Natural Resources (WDNR) ArcGIS REST API sites, which are located here and here. There are a wide variety of services and layers on these sites, and this package helps to make sense of and use these data.
library(wdnr.gis) #> Loading required package: arcpullr #> Loading required package: sf #> Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
Notice that dependency packages arcpullr and sf are loaded along with wdnr.gis. These are essential packages that are used to pull data from an ArcGIS REST API and convert them to an sf object in R. All other functions in wdnr.gis are just wrappers around functions within arcpullr and sf that are specific to WDNR’s ArcGIS REST API.
There are a handful of functions that are written specifically to query certain commonly used layers by using either a spatial or a SQL query. The querying is mostly built in to these functions, but advanced querying functionality is also available.
<- get_hydro_layer(county = "milwaukee")mke_cty_streams
You can also pass an sf object to these get_*_layer functions. This example just shows how to query the watershed that a particular point falls in and the streams within that watershed
<- sf_point(c(-90.8, 43.4)) pt <- get_watershed_layer(sf_object = pt, huc_level = "HUC_8") watershed <- get_hydro_layer(sf_object = watershed)streams
Current functions that query specific WDNR layers are
Others are available upon request. If you have a layer that you use a
lot, email us with a request for a layer specific function and we can
add it in (especially if it will be useful to many others as well).
These functions work similarly to the other specific feature layer functions, but they query the WDNR’s map and image services instead and return a raster.
To get landcover data use the
function. For aerial imagery use the
<- get_wis_landcover(county = "portage") portage_lc plot_layer(portage_lc)
The specific landcover service to be queried can be altered using the
service argument. A full list of available services can be
found by running
list_services(section = "DW_Land_Cover").
<- get_wis_imagery(county = "portage") portage_imagery plot_layer(portage_imagery)
get_wis_landcover the service to be queried
can be altered using the
service argument. A full list of
available image services can be found by running
list_services(section = "DW_Image").
ArcGIS REST APIs are hierarchical in nature. There are one or more folders, each of which contain one or more services. Within services are one or more layers and perhaps sub-layers. The layers contain the data of interest, but we’ve built in functions to be able to find any of the folders, services, or layers using the following functions:
match_sections("trout") #>  "FM_Trout" match_services("trout") #>  "FM_TROUT_ANNO_WTM_Ext" "FM_TROUT_COUNTY_REGS_WTM" #>  "FM_TROUT_HAB_SITES_WTM_Ext" "FM_TROUT_NONDNR_EASEMENTS_WTM_Ext" #>  "FM_TROUT_REGS_WTM_Ext" match_layers("trout stream") #>  "Trout Stream Regulations 2018-2019" "PNW-ASNRI Trout Streams" #>  "Trout Stream Lines"
There are also functions to find specific sections, services, and layers when the name is known. These are most useful when trying to obtain a URL for a specific layer.
list_services("FM_Trout") #>  "FM_TROUT_ANNO_WTM_Ext" "FM_TROUT_COUNTY_REGS_WTM" #>  "FM_TROUT_HAB_SITES_WTM_Ext" "FM_TROUT_NONDNR_EASEMENTS_WTM_Ext" #>  "FM_TROUT_REGS_WTM_Ext"
These functions are most useful when combined for finding specific layers and the associated URLs.
list_layers(services = match_services("trout.*stream")) #> character(0) list_urls(layers = match_layers("trout.*stream")) #>  "https://dnrmaps.wi.gov/arcgis/rest/services/FM_Trout/FM_TROUT_REGS_WTM_Ext/MapServer/0" #>  "https://dnrmaps.wi.gov/arcgis/rest/services/WT_SWDV/WT_Designated_Waters_WTM_Ext/MapServer/5" #>  "https://dnrmaps.wi.gov/arcgis/rest/services/WT_SWDV/WT_Fisheries_Waters_WTM_Ext/MapServer/9"
Notice the use of regular expressions in the