|
3 | 3 | """
|
4 | 4 | import numpy.testing as npt
|
5 | 5 | import pytest
|
6 |
| -from pygmt import info |
| 6 | +from pygmt import Figure, info |
7 | 7 |
|
8 | 8 | gpd = pytest.importorskip("geopandas")
|
9 | 9 | shapely = pytest.importorskip("shapely")
|
@@ -64,3 +64,70 @@ def test_geopandas_info_shapely(gdf, geomtype, desired):
|
64 | 64 | geom = gdf.loc[geomtype].geometry
|
65 | 65 | output = info(table=geom, per_column=True)
|
66 | 66 | npt.assert_allclose(actual=output, desired=desired)
|
| 67 | + |
| 68 | + |
| 69 | +@pytest.mark.mpl_image_compare |
| 70 | +def test_geopandas_plot_default_square(): |
| 71 | + """ |
| 72 | + Check the default behavior of plotting a geopandas DataFrame with Point |
| 73 | + geometry in 2d. |
| 74 | + """ |
| 75 | + point = shapely.geometry.Point(1, 2) |
| 76 | + gdf = gpd.GeoDataFrame(geometry=[point]) |
| 77 | + fig = Figure() |
| 78 | + fig.plot(data=gdf, region=[0, 2, 1, 3], projection="X2c", frame=True) |
| 79 | + return fig |
| 80 | + |
| 81 | + |
| 82 | +@pytest.mark.mpl_image_compare |
| 83 | +def test_geopandas_plot3d_default_cube(): |
| 84 | + """ |
| 85 | + Check the default behavior of plotting a geopandas DataFrame with |
| 86 | + MultiPoint geometry in 3d. |
| 87 | + """ |
| 88 | + multipoint = shapely.geometry.MultiPoint([(0.5, 0.5, 0.5), (1.5, 1.5, 1.5)]) |
| 89 | + gdf = gpd.GeoDataFrame(geometry=[multipoint]) |
| 90 | + fig = Figure() |
| 91 | + fig.plot3d( |
| 92 | + data=gdf, |
| 93 | + perspective=[315, 25], |
| 94 | + region=[0, 2, 0, 2, 0, 2], |
| 95 | + projection="X2c", |
| 96 | + frame=["WsNeZ1", "xag", "yag", "zag"], |
| 97 | + zscale=1.5, |
| 98 | + ) |
| 99 | + return fig |
| 100 | + |
| 101 | + |
| 102 | +@pytest.mark.mpl_image_compare |
| 103 | +def test_geopandas_plot_non_default_circle(): |
| 104 | + """ |
| 105 | + Check the default behavior of plotting geopandas DataFrame with Point |
| 106 | + geometry in 2d. |
| 107 | + """ |
| 108 | + point = shapely.geometry.Point(1, 2) |
| 109 | + gdf = gpd.GeoDataFrame(geometry=[point]) |
| 110 | + fig = Figure() |
| 111 | + fig.plot(data=gdf, region=[0, 2, 1, 3], projection="X2c", frame=True, style="c0.2c") |
| 112 | + return fig |
| 113 | + |
| 114 | + |
| 115 | +@pytest.mark.mpl_image_compare |
| 116 | +def test_geopandas_plot3d_non_default_circle(): |
| 117 | + """ |
| 118 | + Check the default behavior of plotting geopandas DataFrame with MultiPoint |
| 119 | + geometry in 3d. |
| 120 | + """ |
| 121 | + multipoint = shapely.geometry.MultiPoint([(0.5, 0.5, 0.5), (1.5, 1.5, 1.5)]) |
| 122 | + gdf = gpd.GeoDataFrame(geometry=[multipoint]) |
| 123 | + fig = Figure() |
| 124 | + fig.plot3d( |
| 125 | + data=gdf, |
| 126 | + perspective=[315, 25], |
| 127 | + region=[0, 2, 0, 2, 0, 2], |
| 128 | + projection="X2c", |
| 129 | + frame=["WsNeZ1", "xag", "yag", "zag"], |
| 130 | + zscale=1.5, |
| 131 | + style="c0.2c", |
| 132 | + ) |
| 133 | + return fig |
0 commit comments