3

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

6

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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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