Learn R Programming

wikilake

The wikilake package provides functions to scrape the metadata tables from lake pages on Wikipedia.

Installation

Stable release from CRAN

install.packages("wikilake")

Development version

devtools::install_github("jsta/wikilake")

Usage

library(wikilake)
#> Loading required package: maps
# metadata only, see units of numeric fields with wikilake::unit_key_()
lake_wiki("Lake Mendota")
#> Retrieving data from: https://en.wikipedia.org/wiki/Lake_Mendota
#>           Name                             Location                    Type
#> 1 Lake Mendota Dane County, Wisconsin,United States Natural freshwater lake
#>   Primary inflows Primary outflows Catchment area Basin countries Max. length
#> 1    Yahara River     Yahara River            562   United States        9.04
#>   Max. width Surface area Average depth Max. depth Water volume Residence time
#> 1       6.61     39.41654          12.8       25.3           NA            4.5
#>   Shore length1 Surface elevation                              Frozen     Lat
#> 1          34.8               259 December 20 (average freezing date) 43.1066
#>        Lon
#> 1 -89.4247
# use the clean = FALSE argument to get raw data
# (i.e. avoid parsing of numeric fields)
lake_wiki("Lake Mendota", clean = FALSE)
#> Retrieving data from: https://en.wikipedia.org/wiki/Lake_Mendota
#>           Name                             Location                    Type
#> 1 Lake Mendota Dane County, Wisconsin,United States Natural freshwater lake
#>   Primary inflows Primary outflows Catchment area Basin countries Max. length
#> 1    Yahara River     Yahara River     562 [km^2]   United States   9.04 [km]
#>   Max. width Surface area Average depth Max. depth             Water volume
#> 1  6.61 [km] 9740 [acres]      12.8 [m]   25.3 [m] 500 million cubic metres
#>   Residence time Shore length1 Surface elevation
#> 1    4.5 [years]     34.8 [km]           259 [m]
#>                                Frozen     Lat      Lon
#> 1 December 20 (average freezing date) 43.1066 -89.4247
# pretty printing metadata
namevalues_numericvalues_raw
NameLake MendotaLake Mendota
LocationDane County, Wisconsin,United StatesDane County, Wisconsin,United States
TypeNatural freshwater lakeNatural freshwater lake
Primary inflowsYahara RiverYahara River
Primary outflowsYahara RiverYahara River
Catchment area562562 [km^2]
Basin countriesUnited StatesUnited States
Max. length9.049.04 [km]
Max. width6.616.61 [km]
Surface area39.41653922017529740 [acres]
Average depth12.812.8 [m]
Max. depth25.325.3 [m]
Water volumeNA500 million cubic metres
Residence time4.54.5 [years]
Shore length134.834.8 [km]
Surface elevation259259 [m]
FrozenDecember 20 (average freezing date)December 20 (average freezing date)
Lat43.106643.1066
Lon-89.4247-89.4247
# metadata + map
lake_wiki("Gull Lake (Michigan)", map = TRUE)
#> Retrieving data from: https://en.wikipedia.org/wiki/Gull_Lake_(Michigan)

#>        Name                                            Location
#> 1 Gull Lake Kalamazoo / Barry counties, Michigan, United States
#>   Primary outflows Basin countries Surface area Max. depth Surface elevation
#> 1   Gull Creek [1]   United States            8         34               268
#>      Lat     Lon
#> 1 42.399 -85.411
lake_wiki("Gull Lake (Michigan)", map = TRUE, database = "usa")
#> Retrieving data from: https://en.wikipedia.org/wiki/Gull_Lake_(Michigan)

#>        Name                                            Location
#> 1 Gull Lake Kalamazoo / Barry counties, Michigan, United States
#>   Primary outflows Basin countries Surface area Max. depth Surface elevation
#> 1   Gull Creek [1]   United States            8         34               268
#>      Lat     Lon
#> 1 42.399 -85.411
lake_wiki("Lake Nipigon", map = TRUE, regions = "Canada")
#> Retrieving data from: https://en.wikipedia.org/wiki/Lake_Nipigon

#>           Name Location Lake type Primary outflows Catchment area
#> 1 Lake Nipigon  Ontario   Glacial    Nipigon River          25400
#>   Basin countries Surface area Average depth Max. depth Water volume
#> 1          Canada         4848          54.9        165     2.48e+11
#>   Shore length1 Surface elevation   Lat   Lon
#> 1          1044               260 49.83 -88.5
lake_wiki("Cass Lake (Michigan)", map = TRUE, database = "state", regions = "Michigan")
#> Retrieving data from: https://en.wikipedia.org/wiki/Cass_Lake_(Michigan)

#>        Name                 Location Basin countries Surface area Max. depth
#> 1 Cass Lake Oakland County, Michigan   United States     5.179997         37
#>   Surface elevation    Lat     Lon
#> 1               283 42.606 -83.365

Copy Link

Version

Install

install.packages('wikilake')

Monthly Downloads

165

Version

0.7.0

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

January 6th, 2023

Functions in wikilake (0.7.0)

tidy_lake_df

tidy_lake_df
wikilake-package

Scrape Wikipedia lakes metadata
dms2dd

dms2dd
parse_unit_brackets

Parse string representation of units package quantities
get_lake_wiki

get_lake_wiki
lake_wiki_browser

lake_wiki_browser
milakes

Michigan Lakes
lake_wiki

lake_wiki
lake_clean

Clean output of lake_wiki
map_lake_wiki

map_lake_wiki