Database Reference
In-Depth Information
2. Create the
chp03.rk_track_points
table in PostgreSQL by executing
the following command lines:
postgis_cookbook=# CREATE TABLE
chp03.rk_track_points
(
fid serial NOT NULL,
the_geom geometry(Point,4326),
ele double precision,
"time" timestamp with time zone,
CONSTRAINT activities_pk PRIMARY KEY
(fid)
);
3. Create the following script to import all of the
.gpx
files in the
chp03.rk_track_points
table using the GDAL
ogr2ogr
command.
The following is the Linux version (name it
working/chp03/im-
port_gpx.sh
):
#!/bin/bash
for f in `find runkeeper_gpx -name \*.gpx
-printf "%f\n"`
do
echo "Importing gpx file $f to
chp03.rk_track_points PostGIS table..."
#, ${f%.*}"
ogr2ogr -append -update -f
PostgreSQL PG:"dbname='postgis_cookbook'
user='me' password='mypassword'"
runkeeper_gpx/$f -nln
chp03.rk_track_points -sql "SELECT ele,
time FROM track_points"
done
The following is the Windows version (name it
working/chp03/im-
port_gpx.bat
):