Troubles with gmt convert and aspatial when variables are a string

Added by Roelof 3 months ago

Good day,
I just want to make sure I'm not doing something wrong. I'm using the svn version:

Version 6.0.0_r19378 [64-bit] [4 cores]

I can get the aspatial data to play along if it is integers or doubles, but not strings. I find the problem trying to select an extra column (gmt convert -a) or when I want to select a subset (gmt convert -S).

See the following examples with the sample file below (gmt-aspatial.gmt):

# @VGMT1.0 @GPOINT
# @NELEVATION|DISPX|DISPY|NAME|ID
# @Tdouble|double|double|string|integer
# FEATURE_DATA
# @D4.945000|-106500.00000000|-32700.00000000|POINT1|0
-9.36890245902635 39.367156766570389
# @D4.45000|-106500.00000000|-32700.00000000|POINT2|1
-9.3890245902635 39.36715676657039
% gmt convert -a2=NAME gmt-aspatial.gmt
-9.36890245903    39.3671567666
-9.38902459026    39.3671567666
% gmt convert -a2=ELEVATION gmt-aspatial.gmt
-9.36890245903    39.3671567666    4.945
-9.38902459026    39.3671567666    4.45

And the -S option seems problamatic as well.

% gmt convert -a2=ID -S"ID=0" gmt-aspatial.gmt
-9.36890245903    39.3671567666    0
-9.38902459026    39.3671567666    1
% gmt convert -a2=ID -S"ID=1" gmt-aspatial.gmt
%
% gmt convert -SNAME=POINT1 gmt-aspatial.gmt
-9.36890245903    39.3671567666
-9.38902459026    39.3671567666
% gmt convert -SNAME=POINT2 gmt-aspatial.gmt
%    

Thanks for your time.


Replies (3)

RE: Troubles with gmt convert and aspatial when variables are a string - Added by Paul 3 months ago

Thanks Roelof (long time no see). This is probably a consequence of a major rewrite of how text and data mix in GMT and this affected the spatial parsing. Will have a look.

RE: Troubles with gmt convert and aspatial when variables are a string - Added by Paul 3 months ago

Thie first issue should be fixed in r19404. However, your use of -S is not going to work since it only deals with segment headers and those are blank. I will see what is a good solution here and update the docs - they are kind of skinny on this.

RE: Troubles with gmt convert and aspatial when variables are a string - Added by Paul 3 months ago

Somewhat related: I now let -a (i.e, no arguments) mean "append all aspatial items to the input record":

gmt convert -a gmt-aspatial.gmt 
-9.36890245903    39.3671567666    4.945    -106500    -32700    0    POINT1
-9.38902459026    39.3671567666    4.45     -106500    -32700    1    POINT2

Items are appended in the order they are listed in the OGR, with numerical items being added to the numerical record and text items appended to the trailing text part. In r19406.

(1-3/3)