[GRASSLIST:6091] Re: Getting started with postgresql and GRASS

Michael Ash mash at econs.umass.edu
Fri Apr 18 14:11:46 EDT 2003


I have now successfully made GRASS and postgresql
communicate.  The resolution of the shared library problem
was easy thanks to Glynn Clements and is outlined at the end
of this message.

I have two further questions about postgresql and GRASS:

1) How do I connect attribute data in a postgresql database
table with the map geometry if they do not come from the
same .shp,.shx,.dbf trio?  That is, suppose that I have
created a vector map from raw data and I want to create an
associated postgresql table.  How do I define a key column
in the table that is associated with shapes in the vector
map?  Do I have to register the map or otherwise connect a
file in dig_cats with the postgresql table?  Do I have to
give the key column a special name?

To give a simple example, suppose I have created a map of
four neighborhood and would like to highlight the distressed
neighborhoods?

=Vector Map=
Neighborhood
     1
     2
     3
     4


=Table=
Neighborhood  Distressed
     1            1
     2            0
     3            0
     4            1


2) I have downloaded some shapefile trios (.shp,.shx,.dbf)
from the U.S. Census (for example rg99_d00.shp,.shx,.dbf)

http://www.census.gov/geo/www/cob/bdy_files.html

I have attempted to import a dbf file using pg.in.dbf

The GRASS-postgresql commands import the file. The columns
are named properly, but the data in the columns are not
properly divided.  The values for most of the variables end
up in the first column. (When I examine the dbf file in
Excel, the columns are properly divided.)



Follow-up on the original question:

> Michael Ash wrote:
> > GRASS:~ > g.select.pg -l
> > g.select.pg: error while loading shared libraries: libpq.so: cannot load shared object file: No such file or directory

Glynn Clements gave the following advice, which solved the problem:

> If you put shared libraries in a non-standard location (i.e. anywhere
> other than /lib and /usr/lib), you have to tell the loader. E.g.:
>
> 	LD_LIBRARY_PATH=/usr/local/pgsql/lib
> 	export LD_LIBRARY_PATH
>
> Or, if LD_LIBRAY_PATH is already defined:
>
> 	LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgsql/lib
> 	export LD_LIBRARY_PATH
>
> Or add /usr/local/pgsql/lib to /etc/ld.so.conf then run "ldconfig".

Best regards,

Michael Ash, Assistant Professor
  of Economics and Public Policy
Department of Economics and CPPA
University of Massachusetts
Amherst, MA 01003
Tel 413-545-6329 Fax 413-545-2921
Email mash at econs.umass.edu
http://people.umass.edu/maash






More information about the grass-user mailing list