Created
February 4, 2015 21:15
-
-
Save tmcw/f7d335167373fc0dc464 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pprint | |
import json | |
import rasterio | |
from shapely.geometry import Polygon | |
from rasterio import features | |
from shapely.ops import cascaded_union | |
with rasterio.open('logo-bw.png') as src: | |
blue = src.read_band(3) | |
mask = blue < 10 | |
shapes = features.shapes(blue, mask=mask) | |
geojson = { "type": "FeatureCollection", "features": [] } | |
polygons = [] | |
for shape in shapes: | |
p = Polygon(shape[0]['coordinates'][0]) | |
polygons.append(p) | |
mega = cascaded_union(polygons) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: