def makekml(t, lonLatAlt, lat0, lon0, ofn=None): assert isinstance( lonLatAlt, np.ndarray) and lonLatAlt.ndim == 2 and lonLatAlt.shape[1] == 3 kml = Kml(name='My Kml') # doc = kml.newdocument(name='My Doc',snippet=Snippet('snippet')) # doc.lookat.gxtimespan.begin = t[0] # doc.lookat.gxtimespan.end = t[-1] # doc.lookat.latitude = lat0 # doc.lookat.longitude = lon0 # doc.lookat.range = 1e3 #fol = kml.newfolder(name='My Tracks') trk = kml.newgxtrack(name='My Track') trk.newwhen(t) trk.newgxcoord(lonLatAlt.tolist()) #list of lon,lat,alt, NOT ndarray! # Styling (from simplekml docs) # trk.stylemap.normalstyle.iconstyle.icon.href = 'http://earth.google.com/images/kml-icons/track-directional/track-0.png' # trk.stylemap.normalstyle.linestyle.color = '99ffac59' # trk.stylemap.normalstyle.linestyle.width = 6 # trk.stylemap.highlightstyle.iconstyle.icon.href = 'http://earth.google.com/images/kml-icons/track-directional/track-0.png' # trk.stylemap.highlightstyle.iconstyle.scale = 1.2 # trk.stylemap.highlightstyle.linestyle.color = '99ffac59' # trk.stylemap.highlightstyle.linestyle.width = 8 if not ofn: ofn = mkstemp(suffix='.kml')[1] print('writing to', ofn) kml.save(str(ofn))
# <codecell> # The model path and scale variables car_dae = r'http://simplekml.googlecode.com/hg/samples/resources/car-model.dae' car_scale = 1.0 # Create the KML document kml = Kml(name=d.strftime("%Y-%m-%d %H:%M"), open=1) # Create the model model_car = Model(altitudemode=AltitudeMode.clamptoground, orientation=Orientation(heading=75.0), scale=Scale(x=car_scale, y=car_scale, z=car_scale)) # Create the track trk = kml.newgxtrack(name="EKF", altitudemode=AltitudeMode.clamptoground, description="State Estimation from Extended Kalman Filter with CTRV Model") # Attach the model to the track trk.model = model_car trk.model.link.href = car_dae # Add all the information to the track trk.newwhen(car["when"]) trk.newgxcoord(car["coord"]) # Style of the Track trk.iconstyle.icon.href = "" trk.labelstyle.scale = 1 trk.linestyle.width = 4 trk.linestyle.color = '7fff0000'
displayname='Birds Seen') # Create and style a point coords = [(18.36271305597591, -34.01792707074279, 0), (18.36249939144205, -34.01762728515967, 0), (18.36247681257987, -34.01736644626698, 0), (18.36237928017156, -34.01723665897296, 0), (18.36223391902398, -34.0172544563783, 0), (18.36203086107577, -34.01693989513787, 0)] when = [ "2010-05-28T02:00:00Z", "2010-05-28T02:10:00Z", "2010-05-28T02:20:00Z", "2010-05-28T02:30:00Z", "2010-05-28T02:40:00Z", "2010-05-28T02:50:00Z" ] # Create the gx:Track and style it trk = kml.newgxtrack(name='3. World of Birds (Simple Array Data)') trk.snippet = Snippet( 'Click anywhere on the line or open the elevation profile to view the extended data.', 4) trk.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/paddle/3.png' trk.liststyle.itemicon.href = 'http://maps.google.com/mapfiles/kml/paddle/3.png' trk.linestyle.width = 3 trk.linestyle.color = Color.red # Add the coordinates trk.newgxcoord(coords) # Add the time trk.newwhen(when) # Add extended data to the point (view the elevation profile in Google Earth to see the data) trk.extendeddata.schemadata.schemaurl = schema.id
# <codecell> # The model path and scale variables car_dae = r'http://simplekml.googlecode.com/hg/samples/resources/car-model.dae' car_scale = 1.0 # Create the KML document kml = Kml(name=d.strftime("%Y-%m-%d %H:%M"), open=1) # Create the model model_car = Model(altitudemode=AltitudeMode.clamptoground, orientation=Orientation(heading=75.0), scale=Scale(x=car_scale, y=car_scale, z=car_scale)) # Create the track trk = kml.newgxtrack(name="EKF", altitudemode=AltitudeMode.clamptoground, description="State Estimation from Extended Kalman Filter with CTRV Model") gps = kml.newgxtrack(name="GPS", altitudemode=AltitudeMode.clamptoground, description="Original GPS Measurements") # Attach the model to the track trk.model = model_car gps.model = model_car trk.model.link.href = car_dae gps.model.link.href = car_dae # Add all the information to the track trk.newwhen(car["when"]) trk.newgxcoord(car["coord"]) gps.newwhen(car["when"][::5])
# In[32]: # The model path and scale variables car_dae = r'https://raw.githubusercontent.com/balzer82/Kalman/master/car-model.dae' car_scale = 1.0 # Create the KML document kml = Kml(name=d.strftime("%Y-%m-%d %H:%M"), open=1) # Create the model model_car = Model(altitudemode=AltitudeMode.clamptoground, orientation=Orientation(heading=75.0), scale=Scale(x=car_scale, y=car_scale, z=car_scale)) # Create the track trk = kml.newgxtrack(name="EKF", altitudemode=AltitudeMode.clamptoground, description="State Estimation from Extended Kalman Filter with CTRA Model") # Attach the model to the track trk.model = model_car trk.model.link.href = car_dae # Add all the information to the track trk.newwhen(car["when"]) trk.newgxcoord(car["coord"]) # Style of the Track trk.iconstyle.icon.href = "" trk.labelstyle.scale = 1 trk.linestyle.width = 4 trk.linestyle.color = '7fff0000'
# Create and style a point coords = [(18.36271305597591,-34.01792707074279,0), (18.36249939144205,-34.01762728515967,0), (18.36247681257987,-34.01736644626698,0), (18.36237928017156,-34.01723665897296,0), (18.36223391902398,-34.0172544563783,0), (18.36203086107577,-34.01693989513787,0)] when = ["2010-05-28T02:00:00Z", "2010-05-28T02:10:00Z", "2010-05-28T02:20:00Z", "2010-05-28T02:30:00Z", "2010-05-28T02:40:00Z", "2010-05-28T02:50:00Z"] # Create the gx:Track and style it trk = kml.newgxtrack(name='3. World of Birds (Simple Array Data)') trk.snippet = Snippet('Click anywhere on the line or open the elevation profile to view the extended data.', 4) trk.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/paddle/3.png' trk.liststyle.itemicon.href = 'http://maps.google.com/mapfiles/kml/paddle/3.png' trk.linestyle.width = 3 trk.linestyle.color = Color.red # Add the coordinates trk.newgxcoord(coords) # Add the time trk.newwhen(when) # Add extended data to the point (view the elevation profile in Google Earth to see the data) trk.extendeddata.schemadata.schemaurl = schema.id trk.extendeddata.schemadata.newgxsimplearraydata('birdseen', [5,8,10,15,20,30])
} # The model path and scale variables car_dae = r'http://simplekml.googlecode.com/hg/samples/resources/car-model.dae' car_scale = 1.0 # Create the KML document kml = Kml(name="Car", open=1) # Create the model model_car = Model(altitudemode=AltitudeMode.clamptoground, orientation=Orientation(heading=75.0), scale=Scale(x=car_scale, y=car_scale, z=car_scale)) # Create the track trk = kml.newgxtrack(name="Car Track", altitudemode=AltitudeMode.clamptoground, description="Model from: http://sketchup.google.com/3dwarehouse/details?mid=88a57c5396d3703dec0b522a48034ff2") # Attach the model to the track trk.model = model_car trk.model.link.href = car_dae # Add all the information to the track trk.newwhen(car_info["when"]) trk.newgxcoord(car_info["coord"]) # Turn-off default icon and text and hide the linestring trk.iconstyle.icon.href = "" trk.labelstyle.scale = 0 trk.linestyle.width = 0 # Saving