Feature #824

grdcontour - embedding aspatial data for line segments

Added by Andreas almost 2 years ago. Updated 8 months ago.

Status:NewStart date:2015-11-24
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Platform:

Description

Doing a

grdcontour -C1000 -D grid.nc

gives me

> 0 contour -Z0
862550    8149237.88755    0
863050    8149401.40824    0
863550    8149389.84271    0
862550    8149237.88755    0
> 1000 contour -Z1000
440864.613581    7869050    1000
440050    7869564.59938    1000
> 1000 contour -Z1000
468796.339574    7869050    1000
468876.979637    7869550    1000
469163.410145    7871050    1000
> 2000 contour -Z2000
519050    8188133.80058    2000
519550    8188369.9276    2000
520050    8188452.39543    2000

How about including the necessary header and segment information for maximum OGR compatibility?

E.g.

# @VGMT1.0 @GLINESTRING
# @R....           
# @Je....
# @Jp....
# @Jw....
# @Ncontour|type|Z
# @Tdouble|string|double
# FEATURE_DATA
>
# @D0|contour|-Z0
862550    8149237.88755    0
863050    8149401.40824    0
863550    8149389.84271    0
862550    8149237.88755    0
# @D1000|contour|-Z1000
440864.613581    7869050    1000
440050    7869564.59938    1000
# @D1000|contour|-Z1000
468796.339574    7869050    1000
468876.979637    7869550    1000
469163.410145    7871050    1000
# @D2000|contour|-Z2000
519050    8188133.80058    2000
519550    8188369.9276    2000
520050    8188452.39543    2000

History

#1 Updated by Andreas 8 months ago

For anyone looking for the same; pipe the output through a mix of awk (optional) and sed to get an ogr2ogr-ready textfile (windows/cmd version):

#If you want header information, include this. Change @Je if you need to
echo # @VGMT1.0 @GLINESTRING @Ncontour @Tdouble @Je4326 > contours.gmt

grdcontour grid.nc -C10 -D | awk "{print $1, $2}" | sed "s/> /\>\n# @D/g" | sed "s/ contour.*//g" >> contours.gmt

Also available in: Atom PDF