Metropolitan-Council / councilR

A curated collection of commonly used templates, color palettes, functions, and more!
Other
6 stars 1 forks source link

Add helper for connecting to enterprise geodatabase tables in Databases vignette #70

Closed LimerickSam closed 6 months ago

LimerickSam commented 6 months ago

Please assign Sam Limerick to this issue (I'll try to assign myself but not sure if I have access).


When attempting to bring in block-level spatial and population info, the first code block here worked, but the second did not:

blocks2010_spatial <- import_from_gis( query = "GISLibrary.dbo.Census2010TigerBlock", .quiet = TRUE )

blocks2010_popHH <- import_from_gis( query = "GISLibrary.dbo.Census2010PopulationBlock", .quiet = TRUE )

I didn't really expect the second to work, as that file is a Enterprise Geodatabase Table and not a spatial file, but adding some helper code to the vignette may assist future CouncilR users who want to quickly bring in GIS library information that isn't spatial.

eroten commented 6 months ago

import_from_gis() is trying to get the geometry from the table, which doesn't exist.

library(councilR)

options(councilR.uid = "mc\\rotenle",
        councilR.pwd = keyring::key_get("MetC"))

tracts2010_spatial <- import_from_gis(
  query = "GISLibrary.dbo.Census2010TigerTract",
  .quiet = TRUE
)

tracts2010_popHH <- import_from_gis(
  query = "GISLibrary.dbo.Census2010PopulationTract",
  .quiet = TRUE
)
#> Error: nanodbc/nanodbc.cpp:1769: 00000: [FreeTDS][SQL Server]Cannot find either column "Shape" or the user-defined function or aggregate "Shape.STAsText", or the name is ambiguous.  [FreeTDS][SQL Server]Statement(s) could not be prepared. 
#> <SQL> 'SELECT *, Shape.STAsText() as wkt FROM GISLibrary.dbo.Census2010PopulationTract'

Created on 2023-12-22 with reprex v2.0.2