gmt icon indicating copy to clipboard operation
gmt copied to clipboard

Explain -JEPSG:n syntax in the cookbook

Open seisman opened this issue 4 years ago • 15 comments

GMT started to support -JEPSG:n syntax since GMT 6. However, this new feature is only explained in the gmt manpage (https://docs.generic-mapping-tools.org/latest/gmt.html#the-j-option), not in the cookbook (https://docs.generic-mapping-tools.org/latest/cookbook/options.html#option-j).

This feature should be better documented in the cookbook.

seisman avatar Sep 16 '21 10:09 seisman

Yes.

Suggestions:

  • ~How to set GDAL_DATA environment variable (appears to be /usr/share/gdal)~ Not applicable anymore?
  • Add EPSG-codes (where applicable) to Projections specifications table (https://docs.generic-mapping-tools.org/latest/cookbook/options.html#projections-specifications). Can scale, width or both be used with EPSG-codes?
  • Rephrase section on EPSG to reflect changes, ref. discussion below

anbj avatar Sep 16 '21 12:09 anbj

We don't need to set GDAL_DATA. The directory is found automatically.

joa-quim avatar Sep 16 '21 13:09 joa-quim

Ok, maybe reword or add to the paragraph

Using EPSG codes is also possible (but need the setting of the GDAL_DATA environment variable to point to the GDAL’s data sub-directory). For example -JEPSG:4326 sets the WGS-84 system.

I interpreted this as a need to manually add the path to GDAL_DATA.

anbj avatar Sep 16 '21 13:09 anbj

Yes, you are right. Needs rephrasing. That sentence was written before the the magic guessing ability was added to proj4 (LIB_PROJ). Regarding GDAL_DATA now you made me doubt but I'm not sure how much we use of it. The EPSG codes are no longer in GDAL_DATA but instead in LIB_PROJ (which is not needed because it's found automatically $GMT_SHARE/proj).

joa-quim avatar Sep 16 '21 14:09 joa-quim

Ah, OK. So changes indeed.

My GDAL_DATA environment variable is empty (i.e. not set, pr. default).

Also, should I expect to be able to do this?:

$ gmt --show-sharedir
/usr/local/share

$ cd /usr/local/share/proj
bash: cd: /usr/local/share/proj: No such file or directory

Or am I misunderstanding?

anbj avatar Sep 16 '21 14:09 anbj

Or am I misunderstanding?

No, you are on linux 😈

On Windows I added the facility to proj4 to auto-detect the LIB_PROJ when it sits at bin/../share/proj. This was later expanded to *unix and later again it searches not for bin but for directories with respect to the libproj.so (or whatever that lib is called in unix). See

I'm assuming that it also works on *nix but never tried.

joa-quim avatar Sep 16 '21 14:09 joa-quim

Ok!

anbj avatar Sep 22 '21 22:09 anbj

Useful to be documented more: programs using libproj on Windows (made with MINGW) should copy (in the installer script) the msys64/share/proj content to "where_are_my_application_dlls"/../share/proj

GillesDuvert avatar Aug 08 '22 16:08 GillesDuvert

libproj built with MinGW will not work with the official GMT. For it to work the entire GMT must be build with MinGW. But why complicate? GMT comes with a nearly full proj installation. Only the command line tools are not included.

joa-quim avatar Aug 08 '22 18:08 joa-quim

Oh, sorry, this is probably the wrong place to pinpoint this, but I found this page after querying the web about the error: "Cannot find proj.db" and it was very useful to solve my problem, so it was in the hope it could help others. My context is probably specific, but in GDL (the free clone of IDL) we use the proj library to handle projections, and we use the libproj only, not GMT, even if in many installs libproj is present because GMT is installed.

GillesDuvert avatar Aug 09 '22 10:08 GillesDuvert

Interesting, I had never heard of GDL. Thanks for the pointer.

I think that proj.db not found error cannot happen (cross fingers) with an official GMT installation.

joa-quim avatar Aug 09 '22 13:08 joa-quim

Interesting, I had never heard of GDL. Thanks for the pointer.

recent versions permit now to make pretty maps... with projections unknown to IDL :smile image

I think that proj.db not found error cannot happen (cross fingers) with an official GMT installation. most probably no, indeed.

GillesDuvert avatar Aug 09 '22 15:08 GillesDuvert

Nice. Could you try it with GMT? As long as you don’t ask for a frame there are good chances that it works too.

joa-quim avatar Aug 09 '22 15:08 joa-quim

Sorry, I would not know how to do that with GMT!... All graphics, shapefiles, contour cutting & filling, grids etc were done by GDL. Only the projection transformation is activated through a setup of PROJ, in this case it is just with options "+proj=bertin1953 +R=1.0000000". The plot is extracted from the example procedure here, (example 8)

GillesDuvert avatar Aug 09 '22 15:08 GillesDuvert

I think it would be something like (don’t remember how to set ocean land colors), but have no computer around and never mind. It was just curiosity.

coast -Rd -W0.5 -Bg -J”+proj=bertin1953+R=1.0000000+width=10c” -png

joa-quim avatar Aug 09 '22 16:08 joa-quim