Well Known Text is a standard text-based format for defining geometries.
Specify spatial coordinates with the first number as longitude and the second number as latitude.
POINT (-73.935242 40.730610) # LONGITUDE=-73.935242 LATITUDE=40.730610
Note that polygons must be closed, meaning that the first and last coordinates must be the same.
POLYGON ((0 0, 0 1, 1 1)) # BAD
POLYGON ((0 0, 0 1, 1 1, 0 0)) # GOOD
Add holes to polygons by specifying a second set of coordinates.
POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 9, 9 9, 9 1, 1 1))
{ wkt_text : Geometries in WKT format ? Specify each geometry on a separate line }
# CrossCompute
wkt_text_path = 'geometries.txt'
target_folder = '/tmp'
from shapely.geometry import GeometryCollection
from shapely import wkt
geometries = []
for line in open(wkt_text_path):
geometry = wkt.loads(line)
print(geometry)
geometries.append(geometry)
GeometryCollection(geometries)
from geotable import ColorfulGeometryCollection
ColorfulGeometryCollection(geometries)
from cairosvg import svg2png
from os.path import join
target_path = join(target_folder, 'geometries.png')
svg_html = ColorfulGeometryCollection(geometries)._repr_svg_()
svg2png(bytestring=svg_html, write_to=target_path)
print('geometries_image_path = %s' % target_path)
{ geometries_image : Rendered Geometries }