Skip to content

DOC: Add gallery example for using EPSG codes #3973

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

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b888b90
Add first version for gallery example epsg_codes
yvonnefroehlich Jun 13, 2025
c4bd999
Add docs and comments
yvonnefroehlich Jun 13, 2025
9f0fccd
Remove execution permission
yvonnefroehlich Jun 13, 2025
1ddb693
Add code block seperator
yvonnefroehlich Jun 13, 2025
2737204
Shorten URL
yvonnefroehlich Jun 14, 2025
11cef0a
Remove blank line
yvonnefroehlich Jun 14, 2025
dd72248
Use float data type
yvonnefroehlich Jun 14, 2025
1a55f59
Mention EPSG codes in projection files
yvonnefroehlich Jun 15, 2025
7696838
Set link in markdown
yvonnefroehlich Jun 15, 2025
9fce5ca
Use correct URL
yvonnefroehlich Jun 15, 2025
a70141e
Improve formulation
yvonnefroehlich Jun 15, 2025
1c89722
Move to projection gallery
yvonnefroehlich Jun 15, 2025
55feaa7
Remove file
yvonnefroehlich Jun 15, 2025
b10bc32
Use no hypen
yvonnefroehlich Jun 15, 2025
bb571ff
Add blank line at the end
yvonnefroehlich Jun 15, 2025
c762997
Remove execution permission
yvonnefroehlich Jun 15, 2025
b4a7f05
Add subfolder to conf file
yvonnefroehlich Jun 15, 2025
5a20339
Update links to projection gallery
yvonnefroehlich Jun 15, 2025
ea896b2
Color land
yvonnefroehlich Jun 15, 2025
af727f1
Update links to projection gallery
yvonnefroehlich Jun 15, 2025
7d43c72
Shorten link
yvonnefroehlich Jun 16, 2025
5f28e60
Add second url
yvonnefroehlich Jun 16, 2025
c337d10
Fix typo
yvonnefroehlich Jun 18, 2025
1a889e9
Merge branch 'main' into add-gallery-epsg
yvonnefroehlich Jun 18, 2025
c8c5da1
Merge branch 'main' into add-gallery-epsg
yvonnefroehlich Jul 19, 2025
aa48a2d
Merge branch 'main' into add-gallery-epsg
yvonnefroehlich Jul 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
"../examples/projections/cyl",
"../examples/projections/misc",
"../examples/projections/nongeo",
"../examples/projections/table",
"../examples/projections/epsg",
],
# Pattern to search for example files
"filename_pattern": r"\.py",
Expand Down
3 changes: 2 additions & 1 deletion doc/techref/projections.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ myst:

# GMT Map Projections

The table below shows the projection codes for the 31 GMT map projections:
The table below shows the projection codes for the 31 GMT map projections. Besides these
GMT-specific projection codes, [EPSG codes](/projections/epsg) are supported.

| PyGMT Projection Argument | Projection Name |
| --- | --- |
Expand Down
3 changes: 2 additions & 1 deletion examples/projections/GALLERY_HEADER.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Use the ``projection`` parameter to specify which one you want to use in all plo
methods. The projection is specified by a one-letter code along with (sometimes optional)
reference longitude and latitude and the width of the map (for example,
**A**\ *lon0/lat0*\ [*/horizon*\ ]\ */width*). The map height is determined based on the
region and projection.
region and projection. Beside these GMT-specific projection codes,
:doc:`EPSG codes </projections/epsg>` are supported.

These are all the available projections:
2 changes: 2 additions & 0 deletions examples/projections/epsg/GALLERY_HEADER.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
EPSG codes
----------
23 changes: 23 additions & 0 deletions examples/projections/epsg/epsg_codes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
EPSG codes
==========

Besides one of the :doc:`31 projections supported by GMT </techref/projections>`, users
can pass an EPSG (European Petroleum Survey Group) code to the ``projection`` parameter
of the methods :meth:`Figure.basemap` and :meth:`Figure.coast`. A commonly used EPSG
code is ``EPSG:3857``, that refers to the Web Mercator projection WGS84. More
information on the EPSG dataset can be found at https://epsg.org and
https://spatialreference.org/.
"""

# %%
import pygmt

fig = pygmt.Figure()

# Pass the desired EPSG code and the width of the map, here 10 centimeters, to the
# projection parameter
fig.basemap(region=[-180, 180, -60, 60], projection="EPSG:3857/10c", frame=30)
fig.coast(land="gray", shorelines="1/0.1p,gray10")

fig.show()