diff --git a/docs/plot/plot.py b/docs/plot/plot.py index 221f5b560e..b629b20fd1 100755 --- a/docs/plot/plot.py +++ b/docs/plot/plot.py @@ -239,6 +239,27 @@ def resample_polygon(polygon): return Polygon(ext, rings) +def plot_with_interruptions(axes, x, y, delta_cut=1e100, **kwargs): + """ + Plot x/y with proper splitting for interrupted projections. + """ + _x = np.atleast_1d(x) + _y = np.atleast_1d(y) + + dx = np.nan_to_num(_x[1: ]) - np.nan_to_num(_x[0: -1]) + dy = np.nan_to_num(_y[1: ]) - np.nan_to_num(_y[0: -1]) + split, = ((np.abs(dx) > delta_cut) | (np.abs(dy) > delta_cut)).nonzero() + split = np.append(split, _x.size - 1) + split += 1 + + last_part = 0 + for part in split: + axes.plot(x[last_part: part], + y[last_part: part], + **kwargs) + last_part = part + + def plotproj(plotdef, data, outdir): ''' Plot map. @@ -275,7 +296,8 @@ def plotproj(plotdef, data, outdir): pass else: x, y = proj_geom.xy - axes.plot(x, y, color=COLOR_COAST, linewidth=0.5) + plot_with_interruptions(axes, x, y, color=COLOR_COAST, linewidth=0.5, + delta_cut=plotdef.get('delta_cut', 1e100)) # Plot frame frame = [ @@ -286,7 +308,8 @@ def plotproj(plotdef, data, outdir): line = project(line, plotdef['projstring']) x = line[:, 0] y = line[:, 1] - axes.plot(x, y, '-k') + plot_with_interruptions(axes, x, y, color='black', linestyle='-', + delta_cut=plotdef.get('delta_cut', 1e6)) graticule = build_graticule( plotdef['lonmin'], @@ -300,7 +323,28 @@ def plotproj(plotdef, data, outdir): feature = project(feature, plotdef['projstring']) x = feature[:, 0] y = feature[:, 1] - axes.plot(x, y, color=COLOR_GRAT, linewidth=0.4) + plot_with_interruptions(axes, x, y, color=COLOR_GRAT, linewidth=0.4, + delta_cut=plotdef.get('delta_cut', 1e6)) + + # Plot interrupted boundaries if necessary + interrupted_lines = [] + if 'top_interrupted_lons' in plotdef: + for lon in plotdef['top_interrupted_lons']: + for delta in [-0.0001, 0.0001]: + merid = meridian(lon + delta, 0.0, plotdef['latmax']) + interrupted_lines.append(project(merid, plotdef['projstring'])) + + if 'bottom_interrupted_lons' in plotdef: + for lon in plotdef['bottom_interrupted_lons']: + for delta in [-0.0001, 0.0001]: + merid = meridian(lon + delta, plotdef['latmin'], 0) + interrupted_lines.append(project(merid, plotdef['projstring'])) + + for line in interrupted_lines: + x = line[:, 0] + y = line[:, 1] + plot_with_interruptions(axes, x, y, color=COLOR_GRAT, linewidth=0.4, + delta_cut=plotdef.get('delta_cut', 1e100)) # Switch off the axis lines... plt.axis('off') diff --git a/docs/plot/plotdefs.json b/docs/plot/plotdefs.json index f55f5e0ab0..903e2ad8c5 100644 --- a/docs/plot/plotdefs.json +++ b/docs/plot/plotdefs.json @@ -145,7 +145,8 @@ "name": "bipc", "projstring": "+proj=bipc +ns", "res": "low", - "type": "line" + "type": "line", + "delta_cut": 1e6 }, { "filename": "boggs.png", @@ -552,7 +553,10 @@ "name": "igh", "projstring": "+proj=igh", "res": "low", - "type": "line" + "type": "line", + "top_interrupted_lons": [-40.0], + "bottom_interrupted_lons": [80.0, -20.0, -100.0], + "delta_cut": 7e5 }, { "filename": "igh_o.png", @@ -563,7 +567,10 @@ "name": "igh_o", "projstring": "+proj=igh_o +lon_0=-160", "res": "low", - "type": "line" + "type": "line", + "top_interrupted_lons": [110.0, 20.0, -100.0], + "bottom_interrupted_lons": [-70.0, 20.0, 140.0], + "delta_cut": 7e5 }, { "filename": "imw_p.png", @@ -585,7 +592,8 @@ "name": "isea", "projstring": "+proj=isea", "res": "low", - "type": "line" + "type": "line", + "delta_cut": 1e6 }, { "filename": "kav5.png", @@ -740,7 +748,8 @@ "name": "lsat", "projstring": "+proj=lsat +ellps=GRS80 +lat_1=-60 +lat_2=60 +lsat=2 +path=2", "res": "low", - "type": "line" + "type": "line", + "delta_cut": 1e6 }, { "filename": "mbt_s.png", @@ -839,7 +848,8 @@ "name": "misrsom", "projstring": "+proj=misrsom +path=1", "res": "low", - "type": "line" + "type": "line", + "delta_cut": 1e7 }, { "filename": "moll.png", @@ -969,7 +979,7 @@ "lonmax": 180, "lonmin": -180, "name": "ob_tran", - "projstring": "+proj=ob_tran +o_proj=mill +o_lon_p=40 +o_lat_p=50 +lon_0=60", + "projstring": "+proj=ob_tran +o_proj=moll +o_lon_p=40 +o_lat_p=50 +lon_0=60", "res": "low", "type": "poly" }, @@ -1004,7 +1014,8 @@ "name": "omerc", "projstring": "+proj=omerc +lat_1=45 +lat_2=55", "res": "low", - "type": "line" + "type": "line", + "delta_cut": 1e6 }, { "filename": "ortel.png", @@ -1081,7 +1092,8 @@ "name": "peirce_q_horizontal", "projstring": "+proj=peirce_q +lon_0=25 +shape=horizontal", "res": "low", - "type": "line" + "type": "line", + "delta_cut": 1e6 }, { "filename": "grieger_triptychial.png", @@ -1312,7 +1324,8 @@ "name": "gstmerc", "projstring": "+proj=gstmerc", "res": "low", - "type": "line" + "type": "line", + "delta_cut": 1e7 }, { "filename": "tcc.png", @@ -1334,7 +1347,8 @@ "name": "tcea", "projstring": "+proj=tcea", "res": "low", - "type": "line" + "type": "line", + "delta_cut": 1e6 }, { "filename": "times.png", @@ -1444,7 +1458,8 @@ "name": "utm", "projstring": "+proj=utm", "res": "low", - "type": "line" + "type": "line", + "delta_cut": 1e6 }, { "filename": "vandg.png", diff --git a/docs/source/operations/projections/images/aeqd.png b/docs/source/operations/projections/images/aeqd.png index deb3378b8f..7fd53986d4 100644 Binary files a/docs/source/operations/projections/images/aeqd.png and b/docs/source/operations/projections/images/aeqd.png differ diff --git a/docs/source/operations/projections/images/bipc.png b/docs/source/operations/projections/images/bipc.png index 28af6f2c9f..5a522220cb 100644 Binary files a/docs/source/operations/projections/images/bipc.png and b/docs/source/operations/projections/images/bipc.png differ diff --git a/docs/source/operations/projections/images/grieger_triptychial.png b/docs/source/operations/projections/images/grieger_triptychial.png index 2e03a67bfa..ee7874ebd0 100644 Binary files a/docs/source/operations/projections/images/grieger_triptychial.png and b/docs/source/operations/projections/images/grieger_triptychial.png differ diff --git a/docs/source/operations/projections/images/gstmerc.png b/docs/source/operations/projections/images/gstmerc.png index 63e67e8e00..696a36930d 100644 Binary files a/docs/source/operations/projections/images/gstmerc.png and b/docs/source/operations/projections/images/gstmerc.png differ diff --git a/docs/source/operations/projections/images/igh.png b/docs/source/operations/projections/images/igh.png index 10dacf937d..9c41429c11 100644 Binary files a/docs/source/operations/projections/images/igh.png and b/docs/source/operations/projections/images/igh.png differ diff --git a/docs/source/operations/projections/images/igh_o.png b/docs/source/operations/projections/images/igh_o.png index 6fc8f2ee03..9683832b9e 100644 Binary files a/docs/source/operations/projections/images/igh_o.png and b/docs/source/operations/projections/images/igh_o.png differ diff --git a/docs/source/operations/projections/images/isea.png b/docs/source/operations/projections/images/isea.png index b47db36100..f99c3d013e 100644 Binary files a/docs/source/operations/projections/images/isea.png and b/docs/source/operations/projections/images/isea.png differ diff --git a/docs/source/operations/projections/images/lsat.png b/docs/source/operations/projections/images/lsat.png index 8d77e614f2..c1f58642e7 100644 Binary files a/docs/source/operations/projections/images/lsat.png and b/docs/source/operations/projections/images/lsat.png differ diff --git a/docs/source/operations/projections/images/misrsom.png b/docs/source/operations/projections/images/misrsom.png index 7fd327c79e..5c197ae4de 100644 Binary files a/docs/source/operations/projections/images/misrsom.png and b/docs/source/operations/projections/images/misrsom.png differ diff --git a/docs/source/operations/projections/images/ob_tran.png b/docs/source/operations/projections/images/ob_tran.png index d03a24d9ac..dfa1b125d4 100644 Binary files a/docs/source/operations/projections/images/ob_tran.png and b/docs/source/operations/projections/images/ob_tran.png differ diff --git a/docs/source/operations/projections/images/omerc.png b/docs/source/operations/projections/images/omerc.png index fb75512dad..e81d8a4ded 100644 Binary files a/docs/source/operations/projections/images/omerc.png and b/docs/source/operations/projections/images/omerc.png differ diff --git a/docs/source/operations/projections/images/peirce_q_horizontal.png b/docs/source/operations/projections/images/peirce_q_horizontal.png index 615c2abf01..d6612e93f8 100644 Binary files a/docs/source/operations/projections/images/peirce_q_horizontal.png and b/docs/source/operations/projections/images/peirce_q_horizontal.png differ diff --git a/docs/source/operations/projections/images/tcea.png b/docs/source/operations/projections/images/tcea.png index 8bc6bcac79..4e956624e9 100644 Binary files a/docs/source/operations/projections/images/tcea.png and b/docs/source/operations/projections/images/tcea.png differ diff --git a/docs/source/operations/projections/images/utm.png b/docs/source/operations/projections/images/utm.png index c5daf84aab..dfa7c7ed2e 100644 Binary files a/docs/source/operations/projections/images/utm.png and b/docs/source/operations/projections/images/utm.png differ diff --git a/docs/source/operations/projections/ob_tran.rst b/docs/source/operations/projections/ob_tran.rst index 2ede2dd6d0..b25d065ce5 100644 --- a/docs/source/operations/projections/ob_tran.rst +++ b/docs/source/operations/projections/ob_tran.rst @@ -26,7 +26,7 @@ General Oblique Transformation :align: center :alt: General Oblique Transformation - proj-string: ``+proj=ob_tran +o_proj=mill +o_lon_p=40 +o_lat_p=50 +lon_0=60`` + proj-string: ``+proj=ob_tran +o_proj=moll +o_lon_p=40 +o_lat_p=50 +lon_0=60`` Usage ################################################################################