diff --git a/src/gmt_api.c b/src/gmt_api.c index 369fa8ee3c90..0fe1204c2c9f 100644 --- a/src/gmt_api.c +++ b/src/gmt_api.c @@ -5522,6 +5522,10 @@ GMT_LOCAL struct GMT_GRID *gmtapi_import_grid (struct GMTAPI_CTRL *API, int obje else if (S_obj->wesn[XHI] < G_obj->header->wesn[XLO]) { /* Must first wrap G_obj->header->wesn east to fit the data */ G_obj->header->wesn[XLO] -= 360.0; G_obj->header->wesn[XHI] -= 360.0; } + + if (S_obj->wesn[XLO] < G_obj->header->wesn[XLO]) { /* Must wrap G_obj->header.wesn so that west to fit the data */ + G_obj->header->wesn[XLO] -= 360.0; G_obj->header->wesn[XHI] -= 360.0; + } } j1 = (unsigned int)gmt_M_grd_y_to_row (GMT, S_obj->wesn[YLO]+dy, G_obj->header); j0 = (unsigned int)gmt_M_grd_y_to_row (GMT, S_obj->wesn[YHI]-dy, G_obj->header);