Code used to insert a polygon for Champaign County into a PostGIS geometry column.
Note that the sites.geometry
column has three
dimensions. Latitude and longitude are queried using
ggplot2::map_data('counties')
and elevation data is queried
using rgbif::elevation(latidutde, longitude)
.
This query is used to define the boundary of site 1254, Champaign County, which will be used for testing and development of regional runs of PEcAn
### for PostGIS, need polygon to return to start point
champaign <- rbind(champaign, champaign[1])
## need to get key from Google Maps API
## I've put mine in a ~/.googlemapskey
key <- readLines(con = "~/.googlemapskey")
champaign_pts <- data.table(champaign[,elevation(latitude = lat, longitude = long, key = key)])
kable(champaign_pts, caption = "Table with elevations")