diff --git a/src/grdimage.c b/src/grdimage.c index fb57d66f0c5..6a019ed8e3a 100644 --- a/src/grdimage.c +++ b/src/grdimage.c @@ -606,6 +606,12 @@ GMT_LOCAL void grdimage_set_proj_limits (struct GMT_CTRL *GMT, struct GMT_GRID_H if (all_lats) { /* Full -90/+90, use min/max for y */ r->wesn[YLO] = GMT->current.proj.rect[YLO]; r->wesn[YHI] = GMT->current.proj.rect[YHI]; } + if (GMT->current.map.is_world && gmt_M_is_periodic (GMT)) { /* Worry about grids crossing a periodic boundary as the search above may fail */ + if (g->wesn[XLO] < (GMT->current.proj.central_meridian+180) && g->wesn[XHI] > (GMT->current.proj.central_meridian+180)) + r->wesn[XLO] = GMT->current.proj.rect[XLO], r->wesn[XHI] = GMT->current.proj.rect[XHI]; + else if (g->wesn[XLO] < (GMT->current.proj.central_meridian-180) && g->wesn[XHI] > (GMT->current.proj.central_meridian-180)) + r->wesn[XLO] = GMT->current.proj.rect[XLO], r->wesn[XHI] = GMT->current.proj.rect[XHI]; + } } else if (gmt_M_x_is_lon (GMT, GMT_IN)) { /* Extra check for non-projected longitudes that wrap */ double x1;