def drawKMLsForUserCooccurenceGraph(minEdgeWeight=30): kml = SpotsKML() i=1 for edge in FileIO.iterateJsonFromFile(locationGraph): if edge['w']>=minEdgeWeight: kml.addLine(getLocationPairs(edge['e']), description=str(edge['w'])); i+=1 if i==10000: break kml.write(userBasedSpotsKmlsFolder+'%s.kml'%minEdgeWeight)
def writeClusterKML(): kml = SpotsKML() outputKMLFile='%s/clusters.kml'%placesAnalysisFolder%place['name'] for data in FileIO.iterateJsonFromFile(placesUserClusterFeaturesFile%place['name']): clusterId, color, features = data kml.addLocationPointsWithTitles([(getLocationFromLid(f[0].replace('_', ' ')), f[2]) for f in features[:noOfFeatures]], color=color) FileIO.createDirectoryForFile(outputKMLFile) kml.write(outputKMLFile)
def writeUserClusterKMLs(place): clustering = getUserClustering(place, place.get('k')) colorMap = clustering[3] for clusterId, details in sorted(getUserClusteringDetails(place, clustering).iteritems(), key=lambda k: int(k[0])): kml = SpotsKML() kml.addLocationPointsWithTitles([(getLocationFromLid(lid), unicode(name).encode('utf-8')) for lid, name, _ in details['locations'][:5]], color=colorMap[clusterId]) outputKMLFile=placesKMLsFolder%place['name']+'locations/userClusters/%s/%s.kml'%(str(clustering[0]), str(clusterId)) FileIO.createDirectoryForFile(outputKMLFile) kml.write(outputKMLFile)