mdsumner / adrian

Connecting R and Radian
2 stars 0 forks source link

direct to project file #3

Open mdsumner opened 3 years ago

mdsumner commented 3 years ago

This thread shows a way http://www.georeference.org/forum/t153736.3

We'd like to flesh out examples of accessing projection files directly, without configuring the ODBC interface.

This code relies on

I've tried connection strings that use dev builds of Manifold (as listed in the ODBC interface), but the string is too long (?) and gives an error from the odbc package.

library(DBI)
library(odbc)
filepath <- "C:\\temp\\test.map"

template <- "DRIVER={Manifold 9.0 Project Driver (*.map)};DBQ=%s;Unicode=True;Ansi=False;OpenGIS=True;DSN=Default;"
dstring <- sprintf(template, filepath)

con <- dbConnect(odbc::odbc(), .connection_string = dstring)
dbListTables(con)

## need an existing table name  (mfd_meta is always present)
dbReadTable(con, "mfd_meta")

dbGetQuery(con, "SELECT * FROM mfd_meta")

To use dbplyr tbl_lazy needs a bit more groundwork (not yet pushed to this repo): https://twitter.com/mdsumner/status/1318017630981156864/photo/1

mdsumner commented 3 years ago

Here's some notes on direct configuration (the 64-bit interface lives in /system32/ because of legacy in windows, the 32-bit interface is in /SysWOW64

Here's the system interface for configuring named sources (you don't need a project file name for RODBC or odbc):

image