I’m looking at various tools out there for coordinate changes and found PROJ4. I’m aware of GMT tools so I just googled “proj4 vs gmt” and found a word on the subject. I realized the wiki might be outdated, so I thought I would ask the community here. Has GMT (specifically pygmt) already replaced “the gmt_proj.c projection machinery by the proj4 library”?
We have not (yet).
But they run in parallel. If you use a proj4 syntax in mapproject
the coordinate conversions will be done with PROJ4.
Is this the case only for mapproject
?
If I run
gmt pscoast -Jstere/0/90/1:10000000 -Bafg -W -RNO -pdf stereotest
is it gmt
or proj
that does the projection calculation?
Fun: I once wanted to test; gmt vs. proj: is the projection identical?
ps=proj_vs_gmt.ps
#dump coast line and proj to mercator, replace # with >
gmt psxy --PS_MEDIA=A0 \
<(sed "s/#/>/g" <(proj +proj=merc +lon_0=0 +ellps=WGS84 <(sed "s/>/#/g" <(gmt pscoast -ENO -M)))) \
-R0/3460000/7920000/11410000 -P -JX20c -Wthick,black -K > $ps
#project norge.gmt to mercator with GMT
gmt pscoast -ENO -M | gmt mapproject -Jm0/1:100 -R4/32/57/72 -C | \
gmt psxy -R -J -Bafg -BWeSn+t"proj vs. gmt" -O -Wred >> $ps
gmt psconvert -Tg -A -Z $ps
rm gmt.history
Making gmt use proj4 would be a huge deal in my opinion. proj
-stuff is everywhere.
That’s GMT syntax so the projection is done by GMT. Generally the rule is when using proj4 syntax it’s proj4 who does the work. And I say generally because there are (don’t remember the details) some exceptions for making figures where the machinery that calculates the frames works only with with GMT projection stuff. This means that we can make a map with any proj4 supported projection but for many the frames will be screwed. See https://github.com/GenericMappingTools/gmt/issues/5359
So in any case of e.g. -Ja
, -JA
or -Jlaea
it will always be GMT doing the projection. If instead giving a proj-syntax, +proj=merc +lat_ts=56.5 +ellps=GRS80
, proj
does the work?
Edit: not the time or place, but cant help it. The +lat_ts
parameter in a proj
string with mercator, cause funky business. Remove +lat_ts
or set +lat_ts=0
and it’s good. Just for reference.
Try:
gmt pscoast -J"+proj=merc +lat_ts=56.5 +ellps=WGS84" -Bafg -Sblue -Gblack -RNO -pdf test1
gmt pscoast -J"+proj=merc +lat_ts=56.5 +ellps=WGS84" -Bafg -W -RNO -pdf test2
Yes. Despite being called PROJ Codes in table they still refer to GMT codes.
The second of the lat_ts
case surprises me a bit but probably also a consequence of what I said. For figures, using proj4 syntax is expected to fail many times because there are two engines running at same time.
Thanks Joaquim.