Bug #776

gmtspatial polygon clipping artifacts

Added by Ludwig over 1 year ago. Updated over 1 year ago.

Status:ClosedStart date:2015-09-25
Priority:NormalDue date:
Assignee:Paul% Done:


Target version:Candidate for next minor release
Affected version:5.1.x Platform:Linux


Hi everyone,

I just discovered the nice tool gmtspacial, which is very useful to clip polygons to your map boundaries but with some polygons I get unexpected results, messing up the whole process. I've attached two files, the input and the output of the following command:

gmtspatial -C -R65.000/120.000/-80.500/-65.00 cst10_polygon.shelf.org.lb > cst10_polygon.shelf.clipped.lb

The first polygon is cut at the map boundary as expected.
For the second polygon (which is obviously far away from the area) the segment header and the first point is written to the output, which is not critical, but also not nice because it means a lot of unneccessary data.
The third polygon which is also far away from my region however produces a strange artifact. Here a polygon is created which crosses the whole map and makes the resulting image unusable.
I'm using GMT SVN Version 5.1.3_r14870 [64-bit] on Ubuntu 14.04.

Thanks for your help

cst10_polygon.shelf.clipped.lb - result of gmtspatial (4.15 KB) Ludwig, 2015-09-25 01:30

cst10_polygon.shelf.org.lb - original polygon file (8.54 KB) Ludwig, 2015-09-25 01:30

Associated revisions

Revision 14943
Added by Paul over 1 year ago

Address issue #776


#1 Updated by Paul over 1 year ago

  • Status changed from New to Feedback

Before we spend time looking at this, did you try appending -fg to tell gmtspatial that your data are in fact geographic? Does that make any difference?

#2 Updated by Ludwig over 1 year ago

I tried but it changes nothing. As it can be seen at the second polygon, where the first point is rewritten as '234.669528215 -73.5795590559' (originally '-125.330471785 -73.5795590559') shows, that it is already treated as geographical.
Also my first idea was that this is a dateline problem, but the polygon actually leading to the artifact isn't crossing the dateline.

#3 Updated by Paul over 1 year ago

  • Status changed from Feedback to Resolved
  • Assignee set to Paul
  • Target version set to Candidate for next minor release
  • % Done changed from 0 to 100

I found the problems. One was gmtspatial did not actually act on the -fg in this case, and two was the clipping algorithm got confused when a feature straddled the meridian 180-degrees away from either of the two boundaries. In r14943 [GMT 5.2 only - we will release 5.2 next month but you can build from source now if you want].

#4 Updated by Ludwig over 1 year ago

After finally finding out where to find version 5.2, I build it and checked it again. Now it does exactly what I expect.
Thanks a lot!!

#5 Updated by Paul over 1 year ago

  • Status changed from Resolved to Closed

Closing this issue.

Also available in: Atom PDF