Skip to contents

read simple features from PSRC's in-house geodatabase #' This function is preferable to sf::st_read() when pulling from Elmer or ElmerGeo, because it avoids some incompatibilities between SQL Server's data types and R's.

Usage

st_read_elmergeo(layer_name, schema_name = "dbo", project_to_wgs84 = TRUE)

Arguments

layer_name

The name of the feature layer or geodatabase table

schema_name

The name of the schema that layer_name exists in. Defaults to "dbo", the standard schema for ElmerGeo tables

project_to_wgs84

(TRUE/FALSE) If TRUE then deliver the output in WGS84 projection, otherwise NAD84 / WA State Plane North. Defaults to TRUE.

Value

object of class sf

Note

If the layer has been set up as an ESRI versioned layer in the geodatabase, this function returns the versioned view (which exists in SQL Server with a "_evw" suffix). If it has not been set up that way, it returns the base table.

Examples

st_read_elmergeo("COUNTY_BACKGROUND")
#> Simple feature collection with 39 features and 11 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -124.8363 ymin: 45.54373 xmax: -116.9152 ymax: 49.00253
#> Geodetic CRS:  WGS 84
#> First 10 features:
#>    OBJECTID perimeter county_cod county_fip    county_nm psrc SDE_STATE_ID
#> 1         1  983603.8         26        051 Pend Oreille    0            0
#> 2         2 1603655.0         33        065      Stevens    0            0
#> 3         3 1291742.0         10        019        Ferry    0            0
#> 4         4 1497492.0         37        073      Whatcom    0            0
#> 5         5 2046181.0         24        047     Okanogan    0            0
#> 6         6  601010.2         28        055     San Juan    0            0
#> 7         7 1340167.0         29        057       Skagit    0            0
#> 8         8 1357895.0          5        009      Clallam    0            0
#> 9         9 1788454.0          4        007       Chelan    0            0
#> 10       10  568832.4         15        029       Island    0            0
#>                                GlobalID created_user created_date
#> 1  EBAD1EFA-835C-4239-B78F-788D60BEB5DB         <NA>         <NA>
#> 2  019E4313-974E-4FAA-9992-FE1BEDEB5D6A         <NA>         <NA>
#> 3  17F4C595-A5AB-4C66-A9D1-234F3AFCBC32         <NA>         <NA>
#> 4  EEBF0354-6B1A-4945-92AA-ABF3A815F14F         <NA>         <NA>
#> 5  2EDD383C-5CD2-489E-99E8-384DDAC016A1         <NA>         <NA>
#> 6  E900291A-E223-41E1-B3E5-3F7C035A2571         <NA>         <NA>
#> 7  D41D22C9-95B7-4043-90BF-C44139862018         <NA>         <NA>
#> 8  ABCB6C29-A5C9-48B3-BBBA-91FD0BBD376A         <NA>         <NA>
#> 9  90AFC141-B254-42FD-B1E9-32DE8B30102F         <NA>         <NA>
#> 10 7EF77CF7-BF8C-4BED-A050-4331839DFD19         <NA>         <NA>
#>    last_edited_user                          Shape
#> 1              <NA> POLYGON ((-117.4295 49.0004...
#> 2              <NA> POLYGON ((-118.0628 49.0001...
#> 3              <NA> POLYGON ((-118.8366 49.0001...
#> 4              <NA> POLYGON ((-123.0084 48.8296...
#> 5              <NA> POLYGON ((-119.1579 49.0003...
#> 6              <NA> POLYGON ((-123.0084 48.8296...
#> 7              <NA> POLYGON ((-122.7138 48.6450...
#> 8              <NA> POLYGON ((-123.2493 48.2841...
#> 9              <NA> POLYGON ((-120.7021 48.5317...
#> 10             <NA> POLYGON ((-122.7337 48.4130...

st_read_elmergeo("COUNTY_BACKGROUND", project_to_wgs84 = FALSE)
#> Simple feature collection with 39 features and 11 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 664166.8 ymin: -527832.4 xmax: 2636448 ymax: 751796.4
#> Projected CRS: NAD83 / Washington North (ftUS)
#> First 10 features:
#>    OBJECTID perimeter county_cod county_fip    county_nm psrc SDE_STATE_ID
#> 1         1  983603.8         26        051 Pend Oreille    0            0
#> 2         2 1603655.0         33        065      Stevens    0            0
#> 3         3 1291742.0         10        019        Ferry    0            0
#> 4         4 1497492.0         37        073      Whatcom    0            0
#> 5         5 2046181.0         24        047     Okanogan    0            0
#> 6         6  601010.2         28        055     San Juan    0            0
#> 7         7 1340167.0         29        057       Skagit    0            0
#> 8         8 1357895.0          5        009      Clallam    0            0
#> 9         9 1788454.0          4        007       Chelan    0            0
#> 10       10  568832.4         15        029       Island    0            0
#>                                GlobalID created_user created_date
#> 1  EBAD1EFA-835C-4239-B78F-788D60BEB5DB         <NA>         <NA>
#> 2  019E4313-974E-4FAA-9992-FE1BEDEB5D6A         <NA>         <NA>
#> 3  17F4C595-A5AB-4C66-A9D1-234F3AFCBC32         <NA>         <NA>
#> 4  EEBF0354-6B1A-4945-92AA-ABF3A815F14F         <NA>         <NA>
#> 5  2EDD383C-5CD2-489E-99E8-384DDAC016A1         <NA>         <NA>
#> 6  E900291A-E223-41E1-B3E5-3F7C035A2571         <NA>         <NA>
#> 7  D41D22C9-95B7-4043-90BF-C44139862018         <NA>         <NA>
#> 8  ABCB6C29-A5C9-48B3-BBBA-91FD0BBD376A         <NA>         <NA>
#> 9  90AFC141-B254-42FD-B1E9-32DE8B30102F         <NA>         <NA>
#> 10 7EF77CF7-BF8C-4BED-A050-4331839DFD19         <NA>         <NA>
#>    last_edited_user                          Shape
#> 1              <NA> POLYGON ((2457331 747815.8,...
#> 2              <NA> POLYGON ((2305407 741615.1,...
#> 3              <NA> POLYGON ((2119733 735853.9,...
#> 4              <NA> POLYGON ((1116546 674848.3,...
#> 5              <NA> POLYGON ((2042608 734081.5,...
#> 6              <NA> POLYGON ((1116546 674848.3,...
#> 7              <NA> POLYGON ((1185843 605649.2,...
#> 8              <NA> POLYGON ((1052291 477665.4,...
#> 9              <NA> POLYGON ((1672219 558791.7,...
#> 10             <NA> POLYGON ((1178931 521135.8,...