gis_connection | R Documentation |
Functions for interacting with GISLibrary, the primary Met Council ESRI geospatial database.
gis_connection(
dbname = "GISLibrary",
uid = getOption("councilR.uid"),
pwd = getOption("councilR.pwd")
)
import_from_gis(
query,
dbname = "GISLibrary",
uid = getOption("councilR.uid"),
pwd = getOption("councilR.pwd"),
.quiet = FALSE
)
dbname |
character, database name. Default is |
uid |
character, user ID. Default is |
pwd |
character, user password. Default is |
query |
character, string with the database connection and feature class |
.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()
,
emissions_connection()
Other database functions:
FRED_connection()
,
emissions_connection()
## Not run:
library(councilR)
library(DBI)
library(sf)
# set options if you haven't already
options(
councilR.uid = "mc\\uid",
councilR.pwd = "mypwd"
)
# create connection
gis <- gis_connection()
# pull table using SQL and convert to sf
DBI::dbGetQuery(gis, "select *, Shape.STAsText() as wkt from GISLibrary.dbo.AIRPORTS where APNAME ='Flying Cloud'") %>%
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.AIRPORTS", dbname = "GISLibrary")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.