Opened 12 years ago

Closed 12 years ago

#2592 closed defect (worksforme)

extra aspatial data columns written to GMT output from ogr2ogr

Reported by: pcreso Owned by: warmerdam
Priority: low Milestone:
Component: OGR_SF Version: unspecified
Severity: minor Keywords: postgres postgis


Generating GMT output from postgis using ogr2ogr with an SQL included in the ogr2ogr command line generates output with the GMT @N & @T header lines only listing the columns specified in the SQL, but the @D line for each feature has data from the other columns in the database table included.


the command: ogr2ogr -f "GMT" jjj PG:'host=wms dbname=db_trawl user=woodb' -sql "select station_no, simplify(fulltrack,0.0001) as fulltrack from station where fulltrack notnull"

run on a Postgis station table with the following structure:

trip_code | character(7) | not null
station_no | integer | not null
categories | character varying(15) |
area | character(4) |
stn_code | character varying(15) |
stratum | character varying(15) |
course | integer |
date_s | date |
time_s | integer |
fix_s | character(2) |
timefix_s | integer |
lat_s | integer |
nors_s | character(1) |
long_s | integer |


generates the following GMT file:

# @Nstation
# @Tstring

# @D(tan0802,16,RD,ROSS,D1,00012008-02-09,1847,08730279,S,1742266,E,0,337,337,20
174.374799999999993 -73.048467000000002
174.374249999999989 -73.048783
174.373716999999999 -73.049116999999995
174.373199999999997 -73.049417000000005
174.372449999999986 -73.049783000000005

The station_no specified in the SQL is the second value on the @D line, which includes the trip_code, etc as shown.

Change History (2)

comment:1 Changed 12 years ago by warmerdam

Status: newassigned


With GDAL "trunk" I tried:

 ogr2ogr -f GMT out.gmt pline.shp -sql 'select length from pline'

This seemed to work, producing only the length field, and data lines like:

# @D158.033

Do you think the behavior you see is specific to reading from postgres? What version of gdal are you using? Any chance you could try reproducing the problem with a modest sized shapefile that could then be attached?

comment:2 Changed 12 years ago by warmerdam

Component: defaultOGR_SF
Keywords: postgres postgis added; GMT ogr2ogr removed
Resolution: worksforme
Status: assignedclosed

After some further discussion with Brent it appears this problem only occurs with some fairly particular versions of postgres, and is unrelated to the GMT driver. I'm closing as Brent and I feel it would be hard for me to reproduce with systems available to me, and that it is more likely an issue in postgres or the postgres client libraries rather than OGR.

Note: See TracTickets for help on using tickets.