Skip to content

Commit fc1ec77

Browse files
authored
grdcontour: Check that grd has at least 2 roes/columns before trying to contour it. (#9062)
Fix the error reported in forum post https://forum.generic-mapping-tools.org/t/grdcont/6422/2
1 parent 0cd622a commit fc1ec77

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/grdcontour.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,9 +1119,13 @@ EXTERN_MSC int GMT_grdcontour (void *V_API, int mode, void *args) {
11191119

11201120
/* Read data */
11211121

1122-
if (GMT_Read_Data (API, GMT_IS_GRID, GMT_IS_FILE, GMT_IS_SURFACE, GMT_DATA_ONLY, wesn, Ctrl->In.file, G) == NULL) {
1122+
if (GMT_Read_Data(API, GMT_IS_GRID, GMT_IS_FILE, GMT_IS_SURFACE, GMT_DATA_ONLY, wesn, Ctrl->In.file, G) == NULL) {
11231123
Return (API->error);
11241124
}
1125+
if (G->header->n_rows == 1 || G->header->n_columns == 1) {
1126+
GMT_Report(API, GMT_MSG_WARNING, "Contouring grid has only 1 row or 1 column. Cannot do contours for such cases.\n");
1127+
Return(API->error);
1128+
}
11251129

11261130
if (gmt_M_type (GMT, GMT_IN, GMT_Z) == GMT_IS_ABSTIME) { /* Grid data is time */
11271131
/* To properly label contours using GMT time formatting we will rely on the machinery

0 commit comments

Comments
 (0)