gis: GISLibrary

gis_connectionR Documentation

GISLibrary

Description

Functions for interacting with GISLibrary, the primary Met Council ESRI geospatial database.

Usage

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
)

Arguments

dbname

character, database name. Default is "GISLibrary".

uid

character, user ID. Default is getOption("councilR.uid")

pwd

character, user password. Default is getOption("councilR.pwd").

query

character, string with the database connection and feature class

.quiet

logical, whether to print time elapsed message.

Details

  • 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").

Value

gis_connection() - A S4 Microsoft SQL Server object

import_from_gis() - A sf::sf() object or a data frame

See Also

Other database functions: FRED_connection(), emissions_connection()

Other database functions: FRED_connection(), emissions_connection()

Examples

## 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)


Metropolitan-Council/councilR documentation built on March 30, 2024, 2:43 a.m.