-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathtest_tilemap.py
61 lines (54 loc) · 1.49 KB
/
test_tilemap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Test Figure.tilemap.
"""
import pytest
from pygmt import Figure
contextily = pytest.importorskip("contextily")
rioxarray = pytest.importorskip("rioxarray")
@pytest.mark.mpl_image_compare
def test_tilemap_web_mercator():
"""
Create a tilemap plot in Spherical Mercator projection (EPSG:3857).
"""
fig = Figure()
fig.tilemap(
region=[-20000000.0, 20000000.0, -20000000.0, 20000000.0],
zoom=0,
source=contextily.providers.OpenStreetMap.Mapnik,
lonlat=False,
frame="afg",
)
return fig
@pytest.mark.benchmark
@pytest.mark.mpl_image_compare
def test_tilemap_ogc_wgs84():
"""
Create a tilemap plot using longitude/latitude coordinates (OGC:WGS84),
centred on the international date line.
"""
fig = Figure()
fig.tilemap(
region=[-180.0, 180.0, -90, 90],
zoom=0,
source=contextily.providers.OpenStreetMap.Mapnik,
frame="afg",
projection="R180/5c",
)
return fig
@pytest.mark.mpl_image_compare
@pytest.mark.parametrize("no_clip", [False, True])
def test_tilemap_no_clip(no_clip):
"""
Create a tilemap plot clipped to the Southern Hemisphere when no_clip is
False, but for the whole globe when no_clip is True.
"""
fig = Figure()
fig.tilemap(
region=[-180.0, 180.0, -90, 0.6886],
zoom=0,
source=contextily.providers.OpenStreetMap.Mapnik,
frame="afg",
projection="H180/5c",
no_clip=no_clip,
)
return fig