--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/alueet.py Mon Apr 17 22:56:39 2017 +0300 @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +from pprint import pprint +with open('alueet.gmp') as file: + data = file.read() + +shapes = {} +polygons = data.split('@')[1] +for polygon in polygons.splitlines(): + polygon = polygon.split('^') + nimi = polygon[2].rsplit('>', 1)[1] + coordinates = [] + for point in polygon[3].split('~'): + x, y = point.split(',') + coordinates.append((float(x), float(y))) + shapes[nimi.strip().replace('\u200b', '')] = coordinates + +pprint(shapes)