[GRASS-user] Geodatabase and GRASS GIS - how to get the data out
of a geodatabase
stephen sefick
ssefick at gmail.com
Sat Aug 15 23:51:10 EDT 2009
This is what I ended up using:
R:
library(Hmisc)
# Read all tables in the Microsoft Access database blabla.mdb
# perhaps better change to Locale in which the .mdb file was
# generated to avoid that accented table column names are
# getting lost.file first
Sys.setlocale('LC_ALL','C')
Sys.setenv(PATH=paste(Sys.getenv('PATH'),'/sw/bin',sep=':'))
d <- mdb.get('/Users/sefick/Desktop/FtBragg_GeoDataBase_AuburnUNV.mdb')
#create database sqlite3
library(RSQLite)
drv <- dbDriver("SQLite")
con <- dbConnect(drv, dbname = '/Users/sefick/Desktop/GISbragg.db')
for(z in 1:length(d)) dbWriteTable(con, names[z], d[[z]])
dbDisconnect(con)
GRASS:
now I have a database called GISbragg.db and db.in.ogr successfully
imported a table. I need to make a vector out of this. Is there a
way to import the entire database and have them all come in as
vectors?
Stephen Sefick
On Sun, Aug 9, 2009 at 1:35 AM, Markus Neteler<neteler at osgeo.org> wrote:
> On Sun, Aug 9, 2009 at 3:23 AM, stephen sefick<ssefick at gmail.com> wrote:
>> I have a GIS database that is in .mdb format (microsoft access). I
>> have found mdb tools through my debian package manager, but now I
>> don't know how to get the data out of the the database and into GRASS.
>> There are x and y coordinates and other things in the database. Is
>> there a tutorial on how to get the data into GRASS from this database?
>
> I see two ways:
>
> 1) via unixODBC
> For Linux, you need "unixODBC" to be installed (your preferred distribution
> most likely contains this package). As done, get also the MDB Tools,
> compile it with unixodbc support enabled if not already done.
> Then follow instructions at http://www.gdal.org/ogr/drv_pgeo.html
>
> 2) via R
>
> R
> install.packages('Hmisc', dependencies=TRUE)
> library(Hmisc)
> # Read all tables in the Microsoft Access database blabla.mdb
> # perhaps better change to Locale in which the .mdb file was
> # generated to avoid that accented table column names are
> # getting lost.file first
> d <- mdb.get('/path/to/blabla.mdb')
> contents(d)
> for(z in 1:length(d)) print(attributes(d)$names[z])
>
>
> There you are. Now write out to something else with the "foreign"
> package:
>
> install.packages('RSQLite', dependencies=TRUE)
> library(RSQLite)
> drv <- dbDriver("SQLite")
> con <- dbConnect(drv, dbname = '/tmp/blabla.db')
> dbWriteTable(con, "mynewtable", d)
> dbDisconnect(con)
>
> Now you can open '/tmp/blabla.db' with 'sqlite3' or
> other software, e.g. GRASS (import with db.in.ogr).
>
> Cheers
> Markus
>
--
Stephen Sefick
Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.
-K. Mullis
More information about the grass-user
mailing list