-
Notifications
You must be signed in to change notification settings - Fork 229
Figure.grdimage: "img_out" ("A") does not work #2599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks @yvonnefroehlich for writing up this detailed bug report! I can reproduce the error locally, and am wondering if this is a case of #896, whereby the 'plotting' function In the meantime, it might be better to recommend users to use other libraries like |
I tried the following script:
It produces two files: "map.png" and "test_out.tif". "map.png" only has a frame, and "test_out.tif" has no frame. Looking at the source codes, it seems grdimage -A produces an raster image of the current grid, without writing anything to a PS file. @PaulWessel Could you please explain what the purpose and use case of the -A option, so that we can decide if we should have this feature on the PyGMT side? |
Predate wrappers. @joa-quim added it, but cannot imagine it should be available in modern mode? |
The purpose was to use grdimage to directly give a raster image from the grid, with no border etc. But clearly, I think it should be disallowed in modern mode since we cannot tell we are building a PS file. In classic mode I think it is fine and backwards compatible. OK with this, @joa-quim ? |
Why remove? Let me recall that this option let us create GeoTIFF or GeoPDF images independently of the Ghostscript machinery. And if removed it would have to be removed from the grdimage modern mode docs that is the main source of our documentation (the one that opens by default ). I’m not sure how it works in modern mode. Maybe it needs to have a full file name to prevent it to be written in the session directory. |
I agree, just leave it. However, with -A it skips all the PS setup so perhaps @seisman can tell us what confused him - should we improve the docs to make it very clear that -A basically disable the normal PS flow and only writes a raster file and -B etc are not available? |
I'm OK with leaving it as it is.
What's the difference between
and
As I understand it, they're the same, but grdimage -A writes TIFF directly without producing a PS file. Is it equivalent to calling |
Almost, but the first form, the one involving -A, lets us do reprojection, which |
Also, we should give error if -A is used with -B. |
@PaulWessel In PR #2765, I was working on the When I read the |
Don't think so. Lots of places were we dont call GMT_Destroy_Data in the module. They are all handled by the garbage collector gmtlib_garbage_collection when the module ends. |
For wrappers, the The following bash script works:
but the equivalent Python script doesn't:
Using |
PDF is a vector format, not an image. |
I have no idea about what it really does, but the docs says:
I think it means |
Funny that it even works in some cases in PyGMT because in Julia
and that comes from the condition
so I don't see how it can work at all for PyGMT. Is it not detected as an |
In PyGMT, when
|
@joa-quim would know but grdimage -A ends up calling GDAL for writing and I dont know if it is OK there to write a binary image to stdout. |
I don't remember any details but we certainly pass a file name to GDAL for it to save the image. No idea what redirecting to stdout does. Tried and it errors on CLI
|
This doesn't work for GMT CLI. For external wrappers, there are some special handling with |
OK, but actually this complained but worked for me.
|
Yes, it also works in PyGMT, but it crashes if I call
This one also works:
but this one crashes:
I think the equivalent Julia code is:
|
So it crashes when you call
But this is puzzling me
There is no |
There must be a bug in
Probably -F is not being parsed |
Closing the issue because we won't implement it in PyGMT. |
Related to this post in the GMT Forum: https://forum.generic-mapping-tools.org/t/how-to-create-a-geotiff-with-pygmt/4113
The
img_out
(A) parameter ofFigure.grdimage
does not allow to save a grid to a raster format (.bmp, .gif, .jpg, .png, or .tif) as proposed by the documentation https://www.pygmt.org/dev/api/generated/pygmt.Figure.grdimage.html:The relatd GMT code works (see https://docs.generic-mapping-tools.org/dev/grdimage.html#a):
In PyGMT, a figure can be saved as a .bmp, .gif, .jpg, .png, or .tif file via
Figure.savefig
(https://www.pygmt.org/dev/api/generated/pygmt.Figure.savefig.html). But I am not sure whether this is identical to usingimg_out
ofpygmt.Figure.grdimage
.Error message
System information
The text was updated successfully, but these errors were encountered: