forked from jremillard/images-to-osm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindsmallbaseball.py
40 lines (24 loc) · 1.03 KB
/
findsmallbaseball.py
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
30
31
32
import imagestoosm.config as cfg
import os
import QuadKey.quadkey as quadkey
import numpy as np
import shapely.geometry as geometry
from skimage import draw
from skimage import io
import csv
# load up the OSM features into hash of arrays of polygons, in pixels
for classDir in os.listdir(cfg.rootOsmDir) :
if ( classDir == 'baseball') :
classDirFull = os.path.join( cfg.rootOsmDir,classDir)
for fileName in os.listdir(classDirFull) :
fullPath = os.path.join( cfg.rootOsmDir,classDir,fileName)
with open(fullPath, "rt") as csvfile:
csveader = csv.reader(csvfile, delimiter='\t')
pts = []
for row in csveader:
latLot = (float(row[0]),float(row[1]))
pixel = quadkey.TileSystem.geo_to_pixel(latLot,cfg.tileZoom)
pts.append(pixel)
poly = geometry.Polygon(pts);
areaMeters = poly.area * 0.596 *0.596;
print("{}\t{}".format(fileName,areaMeters))