Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a points shapefile that originally came from a GPX file (imported using QGIS). The original GPX file contained waypoints only and has disappeared.

The shapefile has many attributes, but only some have data. Below are these attributes with two example data records (some decimal values discarded to fit onto one row).

  TYPE    IDENT    LAT     LONG      Y_PROJ        X_PROJ          COMMENT
WAYPOINT    JS    -31.6    22.6    -23610488.1    8084542.7    29-AUG-09 13:56
WAYPOINT    PS    -31.6    22.7    -23610333.7    8084487.4    29-AUG-09 14:01

A client of mine would like to convert the shapefile back into GPX, retaining the IDENT attribute as the label for each waypoint; he wants to use the GPX file in Garmin's Basecamp software. I have exported the shapefile sucessfully from both QGIS and ExpertGPS, but when I open the files in Garmin's Basecamp softare, each waypoint has only a sequential number as label.

When I look at the GPX files in a text editor, all the atrribute information is there. For example:

<wpt lat="-31.695305019999999" lon="22.647454610000000">
  <type>WAYPOINT</type>
  <extensions>
    <ogr:IDENT>JS</ogr:IDENT>
    <ogr:LAT>-31.69530502</ogr:LAT>
    <ogr:LONG>22.64745461</ogr:LONG>
    <ogr:Y_PROJ>-23610488.11619880</ogr:Y_PROJ>
    <ogr:X_PROJ>8084542.75904646</ogr:X_PROJ>
    <ogr:COMMENT>29-AUG-09 13:56</ogr:COMMENT>
    <ogr:DISPLAY></ogr:DISPLAY>
    <ogr:SYMBOL></ogr:SYMBOL>
    <ogr:UNUSED1></ogr:UNUSED1>
    <ogr:DIST>0.00</ogr:DIST>
    <ogr:PROX_INDEX></ogr:PROX_INDEX>
    <ogr:COLOR></ogr:COLOR>
    <ogr:ALTITUDE>1382.49</ogr:ALTITUDE>
    <ogr:DEPTH>0.00</ogr:DEPTH>
    <ogr:TEMP>0.00</ogr:TEMP>
    <ogr:WPT_CLASS></ogr:WPT_CLASS>
    <ogr:SUB_CLASS></ogr:SUB_CLASS>
    <ogr:ATTRIB></ogr:ATTRIB>
    <ogr:LINK></ogr:LINK>
    <ogr:STATE></ogr:STATE>
    <ogr:COUNTRY></ogr:COUNTRY>
    <ogr:CITY></ogr:CITY>
    <ogr:ADDRESS></ogr:ADDRESS>
    <ogr:FACILITY></ogr:FACILITY>
    <ogr:CROSSROAD></ogr:CROSSROAD>
    <ogr:UNUSED2></ogr:UNUSED2>
    <ogr:ETE></ogr:ETE>
    <ogr:DTYPE></ogr:DTYPE>
    <ogr:MODEL></ogr:MODEL>
    <ogr:FILENAME></ogr:FILENAME>
    <ogr:LTIME></ogr:LTIME>
  </extensions>

Does anyone know how I could achieve this?

Thanks Hanlie

share|improve this question
add comment

1 Answer

You can use ogr2ogr with the -sql option to specify columns equivalence of the shapefile to the gpx.

Here is an example from the ogr documentation:
ogr2ogr -f GPX output.gpx input.shp -sql "SELECT field1 AS name, field2 AS desc FROM input"

share|improve this answer
    
Thanks, that worked :-) –  user3116 Jun 2 '11 at 13:14
    
Nice, please accept the answer if you wish. (click in the green V button). –  Pablo Jun 2 '11 at 13:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.