From 17a0f12203aaa644c2a5733f342ed2883d9664d7 Mon Sep 17 00:00:00 2001 From: Angel Farguell Caus Date: Wed, 27 May 2020 10:38:03 -0600 Subject: [PATCH] adding bounding box creation in fire detections KML file --- JPSSD.py | 33 ++++++++++++++++++++--- contline.py | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ contlinesvm.py | 2 +- contour2kml.py | 12 +++------ 4 files changed, 118 insertions(+), 13 deletions(-) diff --git a/JPSSD.py b/JPSSD.py index 8a8c6a8..7175a62 100644 --- a/JPSSD.py +++ b/JPSSD.py @@ -1135,6 +1135,32 @@ def json2kml(d,kml_path,bounds,prods,opt='granule',minconf=80.): copyto('kmls/partial1.kml',kml) + # write bounding box + kml.write('\n' + +'Bounding Box\n' + +'\n' + +'Bounds\n' + +'Bounding box of the fire detections\n' + +'\n' + +'\n' + +'\n' + +'0clampToGround\n' + +'\n' + +'%s,%s,0\n' % (bounds[0],bounds[2]) + +'%s,%s,0\n' % (bounds[1],bounds[2]) + +'%s,%s,0\n' % (bounds[1],bounds[3]) + +'%s,%s,0\n' % (bounds[0],bounds[3]) + +'%s,%s,0\n' % (bounds[0],bounds[2]) + +'\n' + +'\n' + +'\n' + +'\n' + +'\n') + # set some constants r = 6378 # Earth radius km_lat = 180/(np.pi*r) # 1km in degrees latitude @@ -1265,17 +1291,17 @@ def json2kml(d,kml_path,bounds,prods,opt='granule',minconf=80.): if conf < 80: kml.write('\n') elif conf < 90: kml.write('\n') else: kml.write('\n') kml.write('\n\n\n\n') @@ -1297,7 +1323,6 @@ def json2kml(d,kml_path,bounds,prods,opt='granule',minconf=80.): kml.write('\n') kml.write('\n') - kml.write('\n\n') print 'Created file %s' % kml_path diff --git a/contline.py b/contline.py index 37087a5..1f13a2d 100644 --- a/contline.py +++ b/contline.py @@ -9,7 +9,90 @@ from JPSSD import time_num2iso from contour2kml import contour2kml from scipy.ndimage import gaussian_filter +def clean_polys(paths,bounds,plot=True): + npaths = [] + maxd = .05 + eps = 1e-5 + dx = abs(bounds[1]-bounds[0]) + dy = abs(bounds[3]-bounds[2]) + xb = np.array(bounds[:2]) + yb = np.array(bounds[2:]) + for p in paths: + diff = np.abs(p[-1]-p[0]) + if (diff>maxd).all() or (abs(diff[0]-dx) - - - """) + + """) for segment in polygon: kml.write("\n%s,%s,0" % tuple(segment)) kml.write(""" - - - - """) + + """) kml.write(""" -- 2.11.4.GIT