[GRASSLIST:2284] output shapefiles - options?

Hi,

I'm working with a series of vector files in Grass 5.7 which I need to export to shapefiles. The geometry is stored as native grass files and the attributes are stored in a PostgreSQL database. I've tried using v.out.ogr but there is a problem with exporting attributes with character data types (all the character attributes are fixed length) :

WARNING: pg driver: column 'sm_name', type 0 is not supported

I can think of a number of possible ways forward - getting ODBC working and connecting to the pg table that way, using a PostGIS database to store geometry and using the pgsql2shp dumper program.

I've tried working with postgis - one problem is I can't get pg.postgisdb to create a database: I've pointed to all the correct files (incidentally, pg.posgisdb seems to be hard coded to look for libpostgis files in ./lib/contrib - I had to create this folder and link in the libpostgis files in from their installed location in ./lib) but get the following:

/usr/local/grass57/scripts/pg.postgisdb: line 199: createdb: command not found

I _can_ connect to an existing postgis db created within psql and new vector files can be created in that database without problem. The problem is that the geometry table contains linestrings for the areas and also points for the label points and pgsql2shp can't write both types into one file and currently doesn't have the option to selectively export geometry types.

Can anyone suggest fixes / tell me if ODBC will export the character columns / suggest another alternative?

Many thanks,
David Orme

Which type pricesely? 'char' should be supported.

Radim

On Monday 19 January 2004 15:54, David Orme wrote:

Hi,

I'm working with a series of vector files in Grass 5.7 which I need to
export to shapefiles. The geometry is stored as native grass files and
the attributes are stored in a PostgreSQL database. I've tried using
v.out.ogr but there is a problem with exporting attributes with

character data types (all the character attributes are fixed length) :
> WARNING: pg driver: column 'sm_name', type 0 is not supported

I can think of a number of possible ways forward - getting ODBC working
and connecting to the pg table that way, using a PostGIS database to
store geometry and using the pgsql2shp dumper program.

I've tried working with postgis - one problem is I can't get
pg.postgisdb to create a database: I've pointed to all the correct
files (incidentally, pg.posgisdb seems to be hard coded to look for
libpostgis files in ./lib/contrib - I had to create this folder and
link in the libpostgis files in from their installed location in ./lib)

but get the following:
> /usr/local/grass57/scripts/pg.postgisdb: line 199: createdb: command
> not found

I _can_ connect to an existing postgis db created within psql and new
vector files can be created in that database without problem. The
problem is that the geometry table contains linestrings for the areas
and also points for the label points and pgsql2shp can't write both
types into one file and currently doesn't have the option to
selectively export geometry types.

Can anyone suggest fixes / tell me if ODBC will export the character
columns / suggest another alternative?

Many thanks,
David Orme

Hi all,

OK - i didn't experiment enough with data types. I was using:

alter table tmp add sm_name char(50);

which gave:

GRASS 5.7.-cvs:~ > v.db.connect -c map=tmp
WARNING: pg driver: column 'sm_name2', type 0 is not supported

If I use:

alter table tmp add sm_name varchar(50);

then the pg driver works fine.

Apologies,
David

On 19 Jan 2004, at 17:25, Radim Blazek wrote:

Which type pricesely? 'char' should be supported.

Radim

On Monday 19 January 2004 15:54, David Orme wrote:

Hi,

I'm working with a series of vector files in Grass 5.7 which I need to
export to shapefiles. The geometry is stored as native grass files and
the attributes are stored in a PostgreSQL database. I've tried using
v.out.ogr but there is a problem with exporting attributes with

character data types (all the character attributes are fixed length) :

WARNING: pg driver: column 'sm_name', type 0 is not supported

I can think of a number of possible ways forward - getting ODBC working
and connecting to the pg table that way, using a PostGIS database to
store geometry and using the pgsql2shp dumper program.

I've tried working with postgis - one problem is I can't get
pg.postgisdb to create a database: I've pointed to all the correct
files (incidentally, pg.posgisdb seems to be hard coded to look for
libpostgis files in ./lib/contrib - I had to create this folder and
link in the libpostgis files in from their installed location in ./lib)

but get the following:

/usr/local/grass57/scripts/pg.postgisdb: line 199: createdb: command
not found

I _can_ connect to an existing postgis db created within psql and new
vector files can be created in that database without problem. The
problem is that the geometry table contains linestrings for the areas
and also points for the label points and pgsql2shp can't write both
types into one file and currently doesn't have the option to
selectively export geometry types.

Can anyone suggest fixes / tell me if ODBC will export the character
columns / suggest another alternative?

Many thanks,
David Orme

You are right,
'char' did not work, because postgres returns internal code of 'bpchar'
for 'char' columns. I have fixed that.

Radim

On Tuesday 20 January 2004 11:27, you wrote:

Hi all,

OK - i didn't experiment enough with data types. I was using:
> alter table tmp add sm_name char(50);

which gave:
> GRASS 5.7.-cvs:~ > v.db.connect -c map=tmp
> WARNING: pg driver: column 'sm_name2', type 0 is not supported

If I use:
> alter table tmp add sm_name varchar(50);

then the pg driver works fine.

Apologies,
David

On 19 Jan 2004, at 17:25, Radim Blazek wrote:
> Which type pricesely? 'char' should be supported.
>
> Radim