Database Reference
In-Depth Information
the script runs the ogr2ogr command, importing the .gpx files to PostGIS using
the GPX GDALdriver (for more details go to http://www.gdal.org/ogr/drv_gpx.html ) .
IntheGDAL'sabstraction,a .gpx fileisanOGRdatasourcecomposedofseveral
layers, as follows:
$ ogrinfo -so 2012-08-29-1930.gpx
Had to open data source read-only
INFO: Open of '2012-08-29-1930.gpx'
using driver `GPX' successful.
1: waypoints (Point)
2: routes (Line String)
3: tracks (Multi Line String)
4: route_points (Point)
5: track_points (Point)
In the .gpx files (OGR data sources), you have just the tracks and
track_points layers. As a shortcut, you could have imported just the tracks
layer using ogr2ogr , but you would need to start using some PostGIS functions
fromthe track_points layerinordertogeneratethe tracks layeritself.Thisis
whyinthe ogr2ogr sectioninthebashscript,weimportthepointgeometriesfrom
the track_ points layer, plus a couple of useful attributes, such as elevation and
timestamp, to the rk_track_points PostGIS table.
Once the records were imported, we fed a new polylines table named tracks
using a subquery and select all of the point geometries and their dates and times
from the rk_track_points table, grouped by date, and with the geometries ag-
gregated using the ST_MakeLine function. This function was able to create lin-
estrings from point geometries (for more details, go to http://www.postgis.org/docs/
ST_MakeLine.html ) .
You should not forget to sort the points in the subquery by datetime ; otherwise,
youwillobtainanirregularlinestring,jumpingfromonepointtotheotherandnotfol-
lowing the correct order.
After loading the tracks table, we tested the two spatial queries.
Search WWH ::




Custom Search