Problems displaying a .grd file in pygmt

156 Views Asked by At

I'm new to pygmt and am having trouble displaying a .grd file.

Here are the two errors I'm receiving when I try to plot it:

grdimage [WARNING]: Your grid y's or latitudes appear to be outside the map region and will be skipped. grdimage [WARNING]: No grid or image inside plot domain

For now, I'm just trying to plot it without a color map and without specifying the projection:

fig.grdimage("/Users/jrtomer/Documents/Winter_Quarter2023/CAPSTONE_RESEARCH/xAlaska_Research_Cruise/QCT_2021+2022.grd")

I tried to define a projection to get it within the map's bounds but got the same error.

fig.grdimage("/Users/jrtomer/Documents/Winter_Quarter2023/CAPSTONE_RESEARCH/xAlaska_Research_Cruise/QCT_2021+2022.grd", projection = 'M15c')

grdimage [WARNING]: Your grid y's or latitudes appear to be outside the map region and will be skipped. grdimage [WARNING]: No grid or image inside plot domain

I also printed out the grid info to try to make sense of the errors but am having trouble understanding why it isn't working. Here is the grid info:

Title: DMagic Data Export Command: Created by DMagic Remark: Gridline node registration used [Cartesian grid] Grid file format: cf = GMT netCDF format (32-bit float, deprecated) x_min: 109575 x_max: 365525 x_inc: 50 name: user_x_unit n_columns: 5120 y_min: 5714075 y_max: 6040425 y_inc: 50 name: user_y_unit n_rows: 6528 v_min: -5193.97128591 v_max: -5.61968876649 name: user_z_unit scale_factor: 1 add_offset: 0 format: classic Default CPT:

Any help is appreciated, thanks!

1

There are 1 best solutions below

0
yvonnefroehlich On

Thanks for trying out PyGMT!

Based on the output of grdinfo, you can see that your data is not provided in longitudes (0-360° or -180-180° East) and latitudes (-90-90° North). Thus, if you specify a Mercator projection (projection="M15c") no data is plotted. You can try plotting the grid using a Cartesian projection with a suitable width or map scale:

import pygmt

pygmt.grdimage(
    grid="/Users/jrtomer/Documents/Winter_Quarter2023/CAPSTONE_RESEARCH/xAlaska_Research_Cruise/QCT_2021+2022.grd",
    # Use a Cartesian projection
    #  with a width, e.g., 15 centimeters
    projection="X15c",  # upper-case X
    # OR
    #  with a map scale, e.g., 1 cm on the map equals 1 km on the ground
    # projection="x1:100000",  # lower-case x
    frame=True,
)

fig.show()