File: visualize.py

package info (click to toggle)
antimeridian 0.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,948 kB
  • sloc: python: 1,165; sh: 8; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 605 bytes parent folder | download | duplicates (2)
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
"""Use this script to make a new image

E.g.:

    python scripts/visualize.py \
        tests/data/input/complex-split.json \
        docs/img/complex-split-uncorrected.png
"""

import json
import sys

import shapely.geometry
from cartopy.crs import PlateCarree
from matplotlib import pyplot

infile = sys.argv[1]
outfile = sys.argv[2]

with open(infile) as f:
    data = json.load(f)

shape = shapely.geometry.shape(data)

axes = pyplot.axes(projection=PlateCarree())
axes.stock_img()
axes.add_geometries(shape, crs=PlateCarree(), color="coral", alpha=0.7)

pyplot.savefig(outfile, bbox_inches="tight")