[postgis-users] Postgis data loading

Brent Wood pcreso at pcreso.com
Thu Apr 7 15:04:01 PDT 2005


Thanks strk/Marcus,

My thanks for the new docs, I did just indulge in a bit if rtfm.

I'm not sure what the "create table" at the end of this section is there for?




Something I haven't asked before, but kept meaning to, about loading data into
PostGIS.

I have found that one of the easiest & most effective way to do this is with
awk & copy, (at least for point data, or two point linestrings)

like:

cat <file> | awk { ... ] | psql $DB -c "copy <table> from stdin ...;"

where I use awk to take each input line, extract the columns with coords &
write out the columns I want with a geometry inserted.

Sticking some tr's & sed in the pipe as well gives a very flexible approach to
loading data. I have some scripts which use this approach to wget some global
datasets, create the tables and zcats the downloaded files through such a
series of pipes to populate the tables.

There is no mention of copy as a means of loading data in the PostGIS docs
(section 4.3), just sequences of insert sqls.

So is there some reason I'm unaware of which makes copy unsuitable, or is it
just an omission? 
 

Brent



More information about the postgis-users mailing list