Importing and Exporting from/to a Garmin GPS
Importing and exporting GRASS vector data from/to GPS unit can be done in many ways. The commands v.in.garmin and v.in.gpsbabel work well for importing track and waypoint data from a GPS. Note however that v.in.garmin requires points and track data to be stored in decimal degree format. A simpler approach for dealing with both import and export of vector data from GRASS cab be done with a little bit of awk and the program gpstrans. A few common examples are listed below. Command names are in boldface type, input files are red, and the resulting GRASS data are in green.
Gpsbabel
From GRASS
# garmin-specific notes here http://www.gpsbabel.org/htmldoc-1.3.2/fmt_garmin.html 1. dowload data vis gpsbabel to GPX: - import with v.in.gpsbabel - convert directly to shp with gps2shp: http://gpx2shp.sourceforge.jp/ (source)
Samples from the command line.
# download waypoints from garmin to GPX file gpsbabel -i garmin -f /dev/ttyS0 -o gpx -F garmin_points.gpx # download track from garmin to GPX file gpsbabel -t -i garmin -f /dev/ttyS0 -o gpx -F garmin_track.gpx # upload to garmin GPS gpsbabel -i gpx -f garmin_points.gpx -o garmin -F /dev/ttyUSB0
Gpstrans
Import all way points with labels starting with "0":
#download all waypoints from gps
gpstrans -dw > all_wpts_5-3.ascii
#output from gpstrans looks like:
Format: UTM UTC Offset: -7.00 hrs Datum[066]: NAD83 W 001 01-MAY-06 22:58 12/31/1989 -7:00:00 10 S 0662251 4039089 W 002 01-MAY-06 23:20 12/31/1989 -7:00:00 10 S 0661915 4039282 W 003 01-MAY-06 23:36 12/31/1989 -7:00:00 10 S 0662224 4039287 W 004 02-MAY-06 00:06 12/31/1989 -7:00:00 10 S 0662002 4039768
#import only those which start with "0" into GRASS
awk '{OFS="|"} $2 ~ /^0.?/{print $9,$10,$2}' all_wpts_5-3.ascii | v.in.ascii out=new_vector columns="x int, y int, id varchar(3)"
Export from points to Garmin GPS:
v.out.ascii spring3 dp=0 | \ awk -F"|" ' BEGIN{ OFS="\t"; print "Format: UTM UTC Offset: -7.00 hrs Datum[066]: NAD83" } { print "W\tP"$3" \t28-MAR-07 20:35 \t12/31/1989 -7:00:00\t10\tS\t0"$1"\t"$2 } ' > garmin_points.waypts
gpstrans -uw garmin_points.waypts
Export new route to Garmin GPS:
v.out.ascii pygmy_route_points \
| awk -F"|" 'BEGIN{OFS="\t"; print "Format: UTM UTC Offset: -7.00 hrs Datum[066]: NAD83\nR\t0\t________________"}
{split($1,easting,"."); split($2,northing,".");
print "W","P"$3,"02-MAY-06 17:19","12/31/1989 -7:00:00","10","S","0"easting[1],northing[1]}' > pygmy_route_points.route
#upload new waypoints to gps
gpstrans -ur pygmy_route_points.route
Software
- General Purpose Programming with Scripting Languages
- LaTeX Tips and Tricks
- PostGIS: Spatially enabled Relational Database Sytem
- PROJ: forward and reverse geographic projections
- GDAL and OGR: geodata conversion and re-projection tools
- R: advanced statistical package
- GRASS GIS: raster, vector, and imagery analysis
- Generic Mapping Tools: high quality map production