Skip to content

Commit 08edf6f

Browse files
committed
Try using GMT_GRID_PIXEL_REG as default instead of GMT_GRID_NODE_REG
Trying to use pixel registration as the default when converting an xarray.DataArray to a virtual GMT grid, instead of gridline registration.
1 parent bb7afdc commit 08edf6f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pygmt/clib/conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def dataarray_to_matrix(grid):
102102
dim
103103
)
104104
)
105-
region.extend([coord.min(), coord.max()])
105+
region.extend([coord.min() - coord_inc / 2, coord.max() + coord_inc / 2])
106106
inc.append(coord_inc)
107107

108108
if any([i < 0 for i in inc]): # Sort grid when there are negative increments

pygmt/clib/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ def create_data(self, family, geometry, mode, **kwargs):
531531
registration : int
532532
The node registration (what the coordinates mean). Can be
533533
``'GMT_GRID_PIXEL_REG'`` or ``'GMT_GRID_NODE_REG'``. Defaults to
534-
``'GMT_GRID_NODE_REG'``.
534+
``'GMT_GRID_PIXEL_REG'``.
535535
pad : int
536536
The grid padding. Defaults to ``GMT_PAD_DEFAULT``.
537537
@@ -565,7 +565,7 @@ def create_data(self, family, geometry, mode, **kwargs):
565565
)
566566
geometry_int = self._parse_constant(geometry, valid=GEOMETRIES)
567567
registration_int = self._parse_constant(
568-
kwargs.get("registration", "GMT_GRID_NODE_REG"), valid=REGISTRATIONS
568+
kwargs.get("registration", "GMT_GRID_PIXEL_REG"), valid=REGISTRATIONS
569569
)
570570

571571
# Convert dim, ranges, and inc to ctypes arrays if given (will be None
@@ -1171,7 +1171,7 @@ def virtualfile_from_matrix(self, matrix):
11711171
yield vfile
11721172

11731173
@contextmanager
1174-
def virtualfile_from_grid(self, grid, registration="GMT_GRID_NODE_REG"):
1174+
def virtualfile_from_grid(self, grid, registration="GMT_GRID_PIXEL_REG"):
11751175
"""
11761176
Store a grid in a virtual file.
11771177

0 commit comments

Comments
 (0)