A large group of images captured using a RedEdge over a central California orchard are available for download here.
With this set extracted to a working folder, this notebook will load all of the images in the set and provide more usage examples of ImageSet data.
%load_ext autoreload
%autoreload 2
from ipywidgets import FloatProgress, Layout
from IPython.display import display
import micasense.imageset as imageset
import os
## This progress widget is used for display of the long-running process
f = FloatProgress(min=0, max=1, layout=Layout(width='100%'), description="Loading")
display(f)
def update_f(val):
if (val - f.value) > 0.005 or val == 1: #reduces cpu usage from updating the progressbar by 10x
f.value=val
images_dir = os.path.expanduser(os.path.join('~','Downloads','RedEdgeImageSet','0000SET'))
%time imgset = imageset.ImageSet.from_directory(images_dir, progress_callback=update_f)
import pandas as pd
data, columns = imgset.as_nested_lists()
print("Columns: {}".format(columns))
df = pd.DataFrame.from_records(data, index='timestamp', columns=columns)
Below we use the mapboxgl extension to plot the measured DLS yaw (or heading) angle from each image's meatadata over the whole imageset. We draw circles at each image location, and then color the circle based on the yaw value.
import math
import numpy as np
from mapboxgl.viz import *
from mapboxgl.utils import df_to_geojson, create_radius_stops, scale_between
from mapboxgl.utils import create_color_stops
#Insert your mapbox token here
token = 'pk.eyJ1IjoibWljYXNlbnNlIiwiYSI6ImNqYWx5dWNteTJ3cWYzMnBicmZid3g2YzcifQ.Zrq9t7GYocBtBzYyT3P4sw'
color_stops = create_color_stops(np.linspace(-math.pi,math.pi,num=8),colors='YlOrRd')
data = df_to_geojson(df,columns[3:],lat='latitude',lon='longitude')
viz = CircleViz(data, access_token=token, color_property='dls-yaw',
color_stops=color_stops,
center=[df['longitude'].median(),df['latitude'].median()],
zoom=16, height='600px',
style='mapbox://styles/mapbox/satellite-streets-v9')
viz.show()