| Title: | Pull Spatial Layers from 'WDNR ArcGIS REST API' |
|---|---|
| Description: | Functions for finding and pulling data from the 'Wisconsin Department of Natural Resources ArcGIS REST APIs' <https://dnrmaps.wi.gov/arcgis/rest/services> and <https://dnrmaps.wi.gov/arcgis2/rest/services>. |
| Authors: | Paul Frater [aut, cre] (ORCID: <https://orcid.org/0000-0002-7237-6563>), Zac Driscoll [aut] (ORCID: <https://orcid.org/0000-0002-8233-0980>) |
| Maintainer: | Paul Frater <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.7 |
| Built: | 2026-05-10 05:14:55 UTC |
| Source: | https://github.com/cran/wdnr.gis |
A package to pull spatial layers from the Wisconsin DNR ArcGIS REST API
The wdnr.gis package provides shortcut functions for working with various spatial layers on the WDNR ArcGIS REST API. Currently, these include: get_hydro_layer, get_watershed_layer, get_roads_layer, get_fmdb_site_layer
These functions retrieve spatial layers that are noted by the middle term in the function name. For example, the get_hydro_layer function retrieve's spatial data from Wisconsin's 24K Rivers and Streams Hydrography layer (or lakes if specified). These functions generally have the same arguments and can be queried by county, sf_object, watershed, or a SQL where statement.
Maintainer: Paul Frater [email protected] (ORCID)
Authors:
Zac Driscoll [email protected] (ORCID)
check_layer_args simply looks at the arguments that is passed to it
and checks to make sure that at least one is not NULL.
avoid_duplicate_sf_args ensures the presence of only one argument that
would result in a downstream spatial query (i.e. only a single sf object
can be used in a spatial query – this function ensures that only one will
be).
deparse_arg_names is just a helper for the above two functions to
format argument names in a useful way
check_layer_args(...) avoid_duplicate_sf_args(...) deparse_arg_names(...)check_layer_args(...) avoid_duplicate_sf_args(...) deparse_arg_names(...)
... |
Any number of objects to be checked |
If any of ... are not NULL, returns nothing. Otherwise stops
function execution.
## Not run: a <- NULL b <- NULL check_layer_args(a, b) ## End(Not run)## Not run: a <- NULL b <- NULL check_layer_args(a, b) ## End(Not run)
Return specific county polygon layer from wi_counties sf object
filter_county_poly(...)filter_county_poly(...)
... |
Any Wisconsin counties provided as character strings, separated by commas |
An sf data.frame with the appropriate counties
## Not run: plot(filter_county_poly("door")) plot_layer(filter_county_poly("portage")) ## End(Not run)## Not run: plot(filter_county_poly("door")) plot_layer(filter_county_poly("portage")) ## End(Not run)
A function that can be used to retrieve the WDNR's Fish Management Database's (FMDB) monitoring site spatial layer. A spatial query can be performed to limit the output of the function by supplying a county name, watershed code, watershed name, or custom sf polygon object. Use the 'watershed_lookup' to find valid watershed codes and names. FMDB site sequance numbers (site_seq) or SWIMS (swims_site_seq) site sequance numbers can be provided to return specific sites. The 'where' arguement can be used to run custom SQL queries.
get_fmdb_site_layer( county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, site_seq = NULL, swims_site_seq = NULL, where = NULL, layer_type = "points", ... )get_fmdb_site_layer( county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, site_seq = NULL, swims_site_seq = NULL, where = NULL, layer_type = "points", ... )
county |
A character object specifying a county name |
watershed_code |
A character object specifying the HUC code for a watershed |
watershed_name |
A character object specifying the HUC name for a watershed |
sf_object |
Any sf polygon object |
site_seq |
A character object or string |
swims_site_seq |
A character object or string |
where |
SQL statement |
layer_type |
Character. Retrieve point stations, polygon stations, or both. |
... |
Additional parameters to pass to
|
A sf object of class multipoints
## Not run: get_fmdb_site_layer(county = "milwaukee") get_fmdb_site_layer(watershed_code = "07070006") get_fmdb_site_layer(site_seq = c(7511,10175131,128290)) get_fmdb_site_layer(county = "waukesha", where = "STATION_TYPE_CODE = 'LAKE'") ## End(Not run)## Not run: get_fmdb_site_layer(county = "milwaukee") get_fmdb_site_layer(watershed_code = "07070006") get_fmdb_site_layer(site_seq = c(7511,10175131,128290)) get_fmdb_site_layer(county = "waukesha", where = "STATION_TYPE_CODE = 'LAKE'") ## End(Not run)
A function that can be used to retrieve WDNR's 24k Hydrography (HYDRO) layer. Either the"24K Hydrography Streams and Rivers" or the "24K Hydrography Lakes and Open Water" can be queried by setting 'layer_type' to 'lines' or 'polygons' respectively. A spatial query can be performed to limit the output of the function by supplying a county name, watershed code, watershed name, or custom sf polygon object. Use the 'watershed_lookup' to find valid watershed codes and names. WBIC's can also be provided in order to return features for specific waterbodies. The 'where' arguement can be used to run custom SQL queries.
get_hydro_layer( county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, wbic = NULL, where = NULL, layer_type = "polygons", ... )get_hydro_layer( county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, wbic = NULL, where = NULL, layer_type = "polygons", ... )
county |
A character object specifying a county name |
watershed_code |
A character object specifying the HUC code for a watershed |
watershed_name |
A character object specifying the HUC name for a watershed |
sf_object |
Any sf polygon object |
wbic |
A character object or string of WBIC's |
where |
SQL statement |
layer_type |
"lines", "polygons", or "flowlines" |
... |
Additional parameters to pass to
|
This function will retrieve WDNR's hydro layer. A county, watershed code, watershed_name, or custom sf polygon can be specifie to filter the layer. The layer type can be specified to query either the polylines or polygons hydro spatial layers.
An sf object of class polylines of polygons
## Not run: get_hydro_layer(county = "milwaukee", layer_type = "lines") get_hydro_layer(watershed_code = "07070006", layer_type = "polygons") get_hydro_layer(wbic = c("549400", "15000"), layer_type = "polygons") get_hydro_layer(county = "milwaukee", where = "HYDROTYPE = '508'") ## End(Not run)## Not run: get_hydro_layer(county = "milwaukee", layer_type = "lines") get_hydro_layer(watershed_code = "07070006", layer_type = "polygons") get_hydro_layer(wbic = c("549400", "15000"), layer_type = "polygons") get_hydro_layer(county = "milwaukee", where = "HYDROTYPE = '508'") ## End(Not run)
A function to retrieve WDNR's roads spatial layers. "layer_type" can be set to "major_roads" or "minor_roads" to query the Major Roads or County and Local Roads respectively. A spatial query can be performed to limit the output of the function by supplying a county name, watershed code, watershed name, or custom sf polygon object. Use the 'watershed_lookup' to find valid watershed codes and names. The "where" argument can be used to run custom SQL queries.
get_roads_layer( county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, where = NULL, layer_type = "all", ... )get_roads_layer( county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, where = NULL, layer_type = "all", ... )
county |
A character object specifying a county name |
watershed_code |
A character object specifying the HUC code for a watershed |
watershed_name |
A character object specifying the HUC name for a watershed |
sf_object |
Any sf polygon object |
where |
SQL statement |
layer_type |
"major_roads" or "minor_roads" |
... |
Additional parameters to pass to
|
A sf object of class polylines
## Not run: get_roads_layer(county = "washington", layer_type = "major_roads") get_roads_layer(watershed_code = "07070006", layer_type = "minor_roads") get_roads_layer(where ="HWY_NUM = '43'",layer_type = "major_roads") ## End(Not run)## Not run: get_roads_layer(county = "washington", layer_type = "major_roads") get_roads_layer(watershed_code = "07070006", layer_type = "minor_roads") get_roads_layer(where ="HWY_NUM = '43'",layer_type = "major_roads") ## End(Not run)
This function will retrieve a watershed boundary from WDNR's ArcGIS Rest Services. A subbasin (HUC8), watershed (HUC 10), or subwatershed (HUC 12) can be retrieved by passing the HUC code or name as a character string. See watershed_lookup for a full list of HUC codes and names. Use filter_huc() to see watersheds by county or classification level.
get_watershed_layer( watershed_code = NULL, watershed_name = NULL, county = NULL, sf_object = NULL, huc_level = NULL, where = NULL, ... )get_watershed_layer( watershed_code = NULL, watershed_name = NULL, county = NULL, sf_object = NULL, huc_level = NULL, where = NULL, ... )
watershed_code |
A character object specifying the HUC code for a watershed |
watershed_name |
A character object specifying the HUC name for a watershed |
county |
A character object specifying a county name |
sf_object |
Any sf polygon object |
huc_level |
"HUC_8","HUC_10", or "HUC_12" |
where |
SQL statement |
... |
Additional parameters that are passed to
|
A function to retrieve a watershed boundary from WDNR's subbasin (HUC8), watershed (HUC 10), or subwatershed (HUC 12) spatial layers. Use 'watershed_lookup' to see a full list of available HUC codes and names.
A sf polygon object
## Not run: get_watershed_layer(watershed_code = "07070006") get_watershed_layer(watershed_name = "Kickapoo") get_watershed_layer(county = "forest",huc_level = "HUC_12") ## End(Not run)## Not run: get_watershed_layer(watershed_code = "07070006") get_watershed_layer(watershed_name = "Kickapoo") get_watershed_layer(county = "forest",huc_level = "HUC_12") ## End(Not run)
Functions to pull layers from the ImageServer and MapServer sections of the Wisconsin Department of Natural Resources ArcGIS REST API . These are raster layers representing various maps and images throughout the state of Wisconsin. Arguments to these function can be used to specify the spatial extent of the output. If no argument is provided, the full raster will be queried.
get_wis_landcover( service = "EN_Land_Cover2_Lev2", county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, ... ) get_wis_imagery( service = "EN_Image_Basemap_Latest_Leaf_Off", county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, ... )get_wis_landcover( service = "EN_Land_Cover2_Lev2", county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, ... ) get_wis_imagery( service = "EN_Image_Basemap_Latest_Leaf_Off", county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, ... )
service |
A string describing the service to be pulled. |
county |
A character object specifying a county name |
watershed_code |
A character object specifying the HUC code for a watershed |
watershed_name |
A character object specifying the HUC name for a watershed |
sf_object |
Any sf polygon object |
... |
Additional arguments to be passed to |
For a full list of available services use the following search options.
– list_services(section = "DW_Land_Cover")
– list_services(section = "DW_Image")
A "RasterLayer" object
## Not run: mke_forest <- get_wis_landcover(county = c("Milwaukee","Forest")) plot_layer(mke_forest, outline_poly = wi_poly, legend = FALSE) ## End(Not run)## Not run: mke_forest <- get_wis_landcover(county = c("Milwaukee","Forest")) plot_layer(mke_forest, outline_poly = wi_poly, legend = FALSE) ## End(Not run)
This is a non-exported function that is used as the engine for
get_wis_landcover and get_wis_imagery. It
converts watersheds, counties, etc. to the appropriate sf_object and
queries the desired service using the function specified in
get_raster_function
get_wis_rasters( service, get_raster_function, county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, ... )get_wis_rasters( service, get_raster_function, county = NULL, watershed_code = NULL, watershed_name = NULL, sf_object = NULL, ... )
service |
Text string describing which service to pull. Will get matched
by |
get_raster_function |
The |
county |
A character object specifying a county name |
watershed_code |
A character object specifying the HUC code for a watershed |
watershed_name |
A character object specifying the HUC name for a watershed |
sf_object |
Any sf polygon object |
... |
Additional arguments to pass to the |
A Raster* object dependent on get_raster_function
These functions can take sections, services, and layers specified as character strings and return either the section, service, layer or url as available in the WDNR GIS REST API
list_sections() list_services(sections = NULL, pull = TRUE) list_layers(sections = NULL, services = NULL, pull = TRUE) list_urls(layers = NULL, sections = NULL, services = NULL, pull = TRUE)list_sections() list_services(sections = NULL, pull = TRUE) list_layers(sections = NULL, services = NULL, pull = TRUE) list_urls(layers = NULL, sections = NULL, services = NULL, pull = TRUE)
sections |
A character vector of available sections to subset by |
pull |
Logical. Pull unique values (TRUE, default) or show the matching rows in the service_urls data.frame |
services |
A character vector of available services to subset by |
layers |
A character vector of available layers to subset by |
A vector of matching sections, services, layers, or URLs depending on the function called
list_sections() list_services(sections = "WT_TMDL") list_layers(services = match_services("Invasive")) list_urls(sections = match_sections("WT"), services = match_services("inland"))list_sections() list_services(sections = "WT_TMDL") list_layers(services = match_services("Invasive")) list_urls(sections = match_sections("WT"), services = match_services("inland"))
list_layers and
list_urls
Helper function to re-create list_layers and
list_urls
list_layer_url(type = "layer", sections = NULL, services = NULL, pull = TRUE)list_layer_url(type = "layer", sections = NULL, services = NULL, pull = TRUE)
type |
Character. The column of data to retrieve from service_urls |
sections |
See |
services |
See |
pull |
See |
A vector of available layers or URLs; depending on type
These functions allow you to search for sections, services, or layers that are available in the WDNR ArcGIS REST API using a regular expression. This is useful when you don't know the full name of a section, service, or layer but want to search based on keywords
match_sections(..., exact = FALSE) match_services(..., sections = NULL, pull = TRUE, exact = FALSE) match_layers(..., sections = NULL, services = NULL, pull = TRUE, exact = FALSE)match_sections(..., exact = FALSE) match_services(..., sections = NULL, pull = TRUE, exact = FALSE) match_layers(..., sections = NULL, services = NULL, pull = TRUE, exact = FALSE)
... |
Character vector or regular expression to match on |
exact |
Logical stating whether to match objects in |
sections |
A character vector of available sections to subset by |
pull |
Logical. Pull unique values (TRUE, default) or show the matching rows in the service_urls data.frame |
services |
A character vector of available services to subset by |
A character vector of all matching sections, services, or layers appropriate to the called function
match_sections("WT") match_services("Fish", sections = match_sections("WT")) match_layers("Fish", sections = match_sections("WT"))match_sections("WT") match_services("Fish", sections = match_sections("WT")) match_layers("Fish", sections = match_sections("WT"))
This function will match the names of a HUC_8 or a HUC_12 watershed found in
the watershed_lookup data set.
match_watershed_name(..., pull = TRUE)match_watershed_name(..., pull = TRUE)
... |
One or more regex passed as character string |
pull |
Logical. Pull the unique values or |
A character string with full watershed names if pull = TRUE, or a data.frame with the number of rows equal to the number of matches otherwise
match_watershed_name("rainbow")match_watershed_name("rainbow")
This function alters string text of county names to a standardized format of lower-cased, no punctuation (i.e. st instead of st.), and underscore instead of spaces
standardize_county_names(...)standardize_county_names(...)
... |
One or more county names in quotations, or a character vector of county names |
A character vector the same length as name, but tidied up
for easier and standard viewing
These are sf polygons that are used for functions and examples throughout the package
watershed_lookup wi_counties wi_polywatershed_lookup wi_counties wi_poly
An object of class data.frame with 2232 rows and 3 columns.
An object of class sf and data.frame:
An object of class sf (inherits from data.frame) with 1 rows and 2 columns.
These datasets are used for functions and examples throughout the package
service_urlsservice_urls
A data.frame