I want to export a GPX file from my postgis database. Luckily I have a name field in postgis, so the 'name' field automatically maps directly over. But I want to export another field into the GPX comment field. How do I do that?

I tried using a -sql statement with 'select name, change as cmt', but when I did that, ogr2ogr lost the geometry field: ERROR 6: Geometry type of `None' not supported in GPX.

I tried adding the geometry field to the sql statement and got ERROR 6: Cannot create GPX layer sql_statement with unknown geometry type. Adding an explicit -geomfield command didn't help - I got the same error.

1 Answer 1


If GDAL has troubles with recognizing the geometry type you can force it with the -nlt (new layer type) parameter. This works for me:

ogr2ogr -f GPX out.gpx -sql "select wkb_geometry, name, namealt as cmt from ne_10m_populated_places" PG:"dbname='dbname' host='localhost' port='5432' user='user' password='passwd'" -nlt point

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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