How to do it...

First, be sure of the format of the .gpx files that you need to import to PostGIS. Open one of them and check the file structure—each file must be in the XML format composed of just one <trk> element, which contains just one <trkseg> element, which contains many <trkpt> elements (the points stored from the runner's GPS device). Import these points to a PostGIS Point table:

  1. Create a new schema named chp03 to store the data for all the recipes in this chapter, using the following command:
      postgis_cookbook=# create schema chp03;
  1. 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), ...

Get PostGIS Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.