gis_connection | R Documentation |
Functions for interacting with GISLibrary, the primary Met Council ESRI geospatial database.
gis_connection(
dbname = "GISLibrary",
uid = keyring::key_get("councilR.uid"),
pwd = keyring::key_get("councilR.pwd")
)
import_from_gis(
query,
dbname = "GISLibrary",
uid = keyring::key_get("councilR.uid"),
pwd = keyring::key_get("councilR.pwd"),
geometry = TRUE,
.quiet = FALSE
)
dbname |
character, database name. Default is |
uid |
character, your network ID.
Default is |
pwd |
character, your network password.
Default is |
query |
character, string with the database connection and feature class |
geometry |
logical, whether to pull the geometry column, if it exists.
Default value is |
.quiet |
logical, whether to print time elapsed message. |
gis_connection()
creates an S4 Microsoft SQL Server object for GISLibrary.
This function will not automatically close the connection, so take
care to use DBI::dbDisconnect()
once you are done.
import_from_gis()
imports a given table from GISLibrary and
converts it into a sf::sf()
object. The connection will
be automatically closed after the table is imported. If the table
does not have any spatial data, the table will be returned as a
data.frame.
Further examples can be found in vignette("Databases", package = "councilR")
.
gis_connection()
- A S4 Microsoft SQL Server object
import_from_gis()
- A sf::sf()
object or a data frame
Other database functions:
FRED_connection()
,
FRED_oracle_connection()
,
emissions_connection()
Other database functions:
FRED_connection()
,
FRED_oracle_connection()
,
emissions_connection()
## Not run:
library(councilR)
library(DBI)
library(sf)
# set credentials if you haven't already
keyring::key_set_with_value("councilR.uid", "mc\\myuuid")
keyring::key_set_with_value("councilR.pwd", "password")
# create connection
gis <- gis_connection()
# pull table using SQL and convert to sf
DBI::dbGetQuery(gis, "select *, Shape.STAsText() as wkt from GISLibrary.dbo.COUNTIES where CO_NAME = 'ANOKA'") %>%
st_as_sf(wkt = "wkt", crs = 26915)
# disconnect
DBI::dbDisconnect(gis)
# import a specific table, with no additional SQL logic
import_from_gis(query = "GISLibrary.dbo.COUNTIES", dbname = "GISLibrary")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.