[postgis-users] transform to postgis

Ethan Alpert ealpert at digitalglobe.com
Mon Oct 4 14:22:37 PDT 2004



Ugh...don't know why that got formatted so bad.  This should look
better:

Something like:

use DBI;

$dbh =
DBI->connect("DBI:Pg:dbname=<dbname>;host=<host>","<user>","<pwd>")
                        or die "Could not connect to db\n"; 

$dbh->do("create table mytable (station int, the_geom geometry)"); 

$dbh->do("CREATE INDEX mytable_oid ON mytable (oid)"); 

$dbh->do("CREATE INDEX mytable_spatial ON mytable USING GIST ( the_geom
GIST_GEOMETRY_OPS)";

while(<>) {
	chomp;
	($id,$east,$north) = split /\s+/;
	$dbh->do("insert into mytable (station,the_geom) value
($id,GeometryFromText('POINT($east $north)',<srid>))");
}




%> cat your.dat | ./thisperl.pl



More information about the postgis-users mailing list