Today we will learn about convex hulls using GeoPandas.
The result is less dramatic when we apply to the map of PR. El resultado.
Today we will learn about convex hulls using GeoPandas.
The result is less dramatic when we apply to the map of PR. El resultado.
import simplejson as json | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import geopandas, shapely | |
tiles = json.loads(file("atlaspr/geotiles/pueblos.json").read()) | |
prTiles = [ {"shape": np.array(x['geometry']['coordinates']), "name": x['properties']['NAME'] } for x in tiles['pueblos']['features']] | |
prTileShapes = [shapely.geometry.shape({"type": "Polygon", "coordinates": tile['shape']}) for tile in prTiles] | |
g = geopandas.GeoSeries(prTileShapes) | |
g.convex_hull.plot() | |
plt.axis("Off") | |
plt.show() |