[GRASS-user] I'm in a hole and want to stop digging
Richard Chirgwin
rchirgwin at ozemail.com.au
Wed Jul 27 05:20:59 EDT 2011
On 27/07/11 11:02 PM, grass-user-request at lists.osgeo.org wrote:
> Message: 5
> Date: Tue, 26 Jul 2011 15:03:11 -0700 (PDT)
> From: Rich Shepard<rshepard at appl-ecosys.com>
> Subject: [GRASS-user] I'm in a hole and want to stop digging
> To:grass-users at lists.osgeo.org
> Message-ID:<alpine.LNX.2.00.1107261448200.665 at salmo.appl-ecosys.com>
> Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII
>
> I'm starting a very large project that involves GRASS, R, and postgres and
> I'm running into difficulties just trying to copy vectors and rasters from
> the PERMANENT mapset into a project-specific mapset. (Setting the region
> also is giving me issues, as will become clear in my explanation.) All this
> with -6.5svn on linux.
>
> I have DEM raster data and some vector data stored in the internal GRASS
> .dbf format. The rest of the vector data are postgres tables. When I invoke
> grass65, I immediately run 'db.connect driver=pg database=nevada' so g.list
> vect shows me all vector map tables. But, it does not distinguish between
> those in postgres and those in GRASS.
>
> An example: looking at the output of 'g.list vect' I see the county
> boundary ('county_bnd'), but a table list in postgres shows 'county_bnd_arc'
> and 'county_bnd_lab'. When I try to use g.copy I get errors whether I use
> 'county_bnd' or 'county_bnd_arc'. So, I put that aside and try to copy map
> huc10:
>
> GRASS 6.5.svn (Nevada-SPCS):~/grassdata> g.copy vect=huc10 at PERMANENT,huc10
> Copy vector<huc10 at PERMANENT> to current mapset as<huc10>
> DBMI-Postgres driver error:
> Cannot create table:
> create table huc10 ( cat integer, gaz_id integer, area_acres double
> precision, area_sqkm double precision, states varchar(50), loaddate
> varchar(10), huc_10 varchar(10), hu_10_name varchar(120), hu_10_type
> varchar(1), hu_10_mod varchar(50), shape_leng double precision, shape_area
> double precision )
> ERROR: relation "huc10" already exists
>
>
> WARNING: Unable to create table<huc10>
> WARNING: Unable to copy table<huc10>
> WARNING: Cannot copy<huc10 at PERMANENT> to current mapset as<huc10>
>
> Well, huc10_does_ exist in postgres (I imported it to the PERMANENT
> mapset), but it's not available in the jerritt mapset.
>
> Because working with both the internal and an external dbms for vector
> data is new to me I'd greatly appreciate pointers to what I need to read to
> learn how to get past this hurdle so I can motor up to the next hurdle.
> There's a lot of learning on my part, and client pressure to start producing
> analytical results.
>
> Rich
>
Rich,
So - the pg database server is a local server?
If I understand you correctly, here is what is happening:
g.copy vector=map at PERMANENT,map
Grass-GIS can copy the map (ie topology etc) fine, because there's no
clash. But if a table called "map" already exists in the database, the
copy fails.
My approach - I use MySQL but don't see why this would not work in pg -
is to associate a schema to a mapset. So if I want PERMANENT and
Project, over in MySQL I might run:
create database Master
create database Project
Back in Grass-GIS ... in each mapset:
PERMANENT
db.connect driver=mysql database=host=localhost,dbname=Master
Project
db.connect driver=mysql database=host=localhost,dbname=Project
Then, when I copy a map from PERMANENT to Project, there is no table in
the target schema to upset the copying process.
Cheers,
Richard Chirgwin
More information about the grass-user
mailing list