[postgis-users] transform to postgis

Paul Ramsey pramsey at refractions.net
Mon Oct 4 14:33:21 PDT 2004


BTW: it is always better practice to create your indexes *after* your 
bulk load, otherwise you end up doing an index update for every insert 
(expensive!)

Ethan Alpert wrote:

> 
> 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
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list