You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Geographic xarray.DataArray grid is plotted as Cartesian grid #1172
Here is a minimal script to reproduce the issue. It extracts a subregion from the earth_relief_01d grid, and then plot it using grdview. It's a geographic grid and should use a geographic projection, but it uses a Cartesian projection (see the image above).
Here is what happens: Your GMT_GRID_IS_GEO bit-flag only leads to a call to gmt_set_geographic (GMT, GMT_OUT); inside GMT_Create_Data. Never mind that you did not pass GMT_IS_OUTPUT so this should be considered a grid for input, not output [I think I need to fix that bug which probably is not affecting many things anyway]. But even so, once your fig.grdview command is run a new session is created (right?) so there is no memory of setting anything to geographic. The solution is clearly to embed this info in the GMT_MATRIX structure, and that will mean in its void *hidden structure since there is no attribute in the GMT_MATRIX structure to hold that information. If we add a flag in the hidden struct that is set to geo then the GMT_Read_Data branch dealing with input matrices can explore that setting and call gmt_set_geographic as needed. I think that is the solution here. Agree?
Activity
seisman commentedon Apr 4, 2021
@PaulWessel This looks like an upstream GMT bug.
Here is a minimal script to reproduce the issue. It extracts a subregion from the earth_relief_01d grid, and then plot it using
grdview. It's a geographic grid and should use a geographic projection, but it uses a Cartesian projection (see the image above).Internally, PyGMT calls the
GMT_Create_Datafunction, and then callsGMT_Put_Matrix. Here are the arguments passed toGMT_Create_Data:PaulWessel commentedon Apr 4, 2021
Here is what happens: Your GMT_GRID_IS_GEO bit-flag only leads to a call to
gmt_set_geographic (GMT, GMT_OUT);inside GMT_Create_Data. Never mind that you did not pass GMT_IS_OUTPUT so this should be considered a grid for input, not output [I think I need to fix that bug which probably is not affecting many things anyway]. But even so, once your fig.grdview command is run a new session is created (right?) so there is no memory of setting anything to geographic. The solution is clearly to embed this info in the GMT_MATRIX structure, and that will mean in itsvoid *hiddenstructure since there is no attribute in the GMT_MATRIX structure to hold that information. If we add a flag in the hidden struct that is set to geo then the GMT_Read_Data branch dealing with input matrices can explore that setting and call gmt_set_geographic as needed. I think that is the solution here. Agree?seisman commentedon Apr 5, 2021
The issue has been fixed in GenericMappingTools/gmt#5091 and GenericMappingTools/gmt#5092