diff options
| author | Howard Butler <howard@hobu.co> | 2020-10-14 14:40:42 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-14 14:40:42 -0500 |
| commit | a762daddb54be6e697375f8ed347cdf0aeaf4477 (patch) | |
| tree | ae7e720c8512c02490a10448f12f264cea49b678 /docs/plot/plot.py | |
| parent | bb7dde0752bfb35389b536b2ee6cd37f94f0a511 (diff) | |
| download | PROJ-a762daddb54be6e697375f8ed347cdf0aeaf4477.tar.gz PROJ-a762daddb54be6e697375f8ed347cdf0aeaf4477.zip | |
Plot building Github Action (#2377)
* implement conda package building
* paths
* need libtool
* PLATFORM check
* point to my PROJ feedstock for now
* point to PROJ repos
* plot building and artifact upload
* syntax
* add proj conda package for plotting
* retab
* no doxygen
* syntax
* update docs Makefile
* doc building
* needs
* consolidate doc/plots
* plot updates
* put updated plot output into docs
* register spelling module
* use v2 download-artifact
* artifact upload
Diffstat (limited to 'docs/plot/plot.py')
| -rw-r--r-- | docs/plot/plot.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/docs/plot/plot.py b/docs/plot/plot.py index 1822f347..13ed332c 100644 --- a/docs/plot/plot.py +++ b/docs/plot/plot.py @@ -46,6 +46,7 @@ from __future__ import division import os import os.path +import shutil import sys import json import subprocess @@ -61,8 +62,12 @@ from shapely.geometry import shape from shapely.ops import transform from descartes import PolygonPatch -PROJ = os.environ.get('PROJ_EXE', '../../src/proj') -PROJ_LIB = '../../data' +PROJ_COMMAND = os.environ.get('PROJ_EXE', '../../src/proj') +if not os.path.exists(PROJ_COMMAND): + PROJ = shutil.which(PROJ_COMMAND) +else: + PROJ = PROJ_COMMAND +PROJ_LIB = os.environ.get('PROJ_LIB', '../../data') LINE_LOW = 'data/coastline.geojson' LINE_MED = 'data/coastline50.geojson' @@ -160,9 +165,9 @@ def project(coordinates, proj_string, in_radians=False): try: proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env={'PROJ_LIB': os.path.abspath(PROJ_LIB)}) - except FileNotFoundError: + except FileNotFoundError as e: print("'proj' binary not found, set the PROJ_EXE environment variable " - "to point to your local 'proj' binary") + "to point to your local 'proj' binary --%s--" % e) exit(1) stdout, _ = proc.communicate(coordinates.tobytes(order='C')) @@ -223,7 +228,10 @@ def resample_polygon(polygon): ''' Use interp_coords() to resample (multi)polygons. ''' - xy = polygon.exterior.coords.xy + try: + xy = polygon.exterior.coords.xy + except AttributeError: #no xy's + return polygon ext = interp_coords(xy, 2) # interiors rings = [] @@ -267,8 +275,11 @@ def plotproj(plotdef, data, outdir): proj_geom = transform(trans, pol) if plotdef['type'] == 'poly': - patch = PolygonPatch(proj_geom, fc=COLOR_LAND, zorder=0) - axes.add_patch(patch) + try: + patch = PolygonPatch(proj_geom, fc=COLOR_LAND, zorder=0) + axes.add_patch(patch) + except TypeError: + pass else: x, y = proj_geom.xy axes.plot(x, y, color=COLOR_COAST, linewidth=0.5) |
