def export(cls, folder, particles, datetimes):
        """
            Export trackline data to GeoJSON file
        """
        normalized_locations = [particle.normalized_locations(datetimes) for particle in particles]

        track_coords = []
        for x in xrange(0, len(datetimes)):
            points = MultiPoint([loc[x].point.coords[0] for loc in normalized_locations])
            track_coords.append(points.centroid.coords[0])

        ls = LineString(track_coords)

        if not os.path.exists(folder):
            os.makedirs(folder)
        filepath = os.path.join(folder, "trackline.geojson")
        f = open(filepath, "wb")
        f.write(json.dumps(mapping(ls)))
        f.close()
        return filepath
def export ( cls , folder , particles , datetimes ) : normalized_locations = [ particle . normalized_locations ( datetimes ) for particle in particles ] track_coords = [ ] for x in xrange ( 0 , len ( datetimes ) ) : points = MultiPoint ( [ loc [ x ] . point . coords [ 0 ] for loc in normalized_locations ] ) track_coords . append ( points . centroid . coords [ 0 ] ) ls = LineString ( track_coords ) if not os . path . exists ( folder ) : os . makedirs ( folder ) filepath = os . path . join ( folder , "trackline.geojson" ) f = open ( filepath , "wb" ) f . write ( json . dumps ( mapping ( ls ) ) ) f . close ( ) return filepath
Export trackline data to GeoJSON file