
Turn Your Tracklogs into ESRI Shapefiles #71
Chapter 6, Mapping on Your Desktop
|
341
HACK
Time::Piece to tell it how to parse the timestamp in each tracklog entry. If
you need to alter it for any reason, refer to the manual page for strptime(3)
on your system for the syntax. One could make this “Do What I Mean” in
more and different circumstances by replacing
Time::Piece with Date::
Parse
from the CPAN, which would be more flexible but far less efficient.
Finally, note the use of the
$shp->{ShapeRecords} array, which allows us to
associate other data values with each feature in the shapefile. The data fields
are defined by
$shp->{FieldNames} and $shp->{FieldTypes}, about which
you can read more in
perldoc Geo::Shapelib. The important thing is that
Geo::Shapelib stores the values from $shp->{ShapeRecords} in the resulting .
dbf file, which you can read with most modern spreadsheet programs, such
as Gnumeric or Excel. Load the .dbf file produced by track2shp.pl in one of
these programs, and you should see two columns. The first is an arbitrary
numeric identifier for each feature that track2shp.pl found in the tracklog,
and the second is the date on which that feature was finally recorded, which
is returned from the call to
$previous->ymd. Obviously, with a little experi-
mentation, you can add more fields and put all kinds of other stuff in here,
such as the start and stop times of each individual track, ...