In [ ]:
%matplotlib inline
from IPython.display import display, Image
from geonotebook.wrappers import VectorData
import matplotlib.pylab as plt
from math import log

In [ ]:
EXPECTED="https://data.kitware.com/api/v1/item/589b38c58d777f07219fcb3b/download"
# Set the center of the map to the location the data
M.set_center(-98.58, 39.83, 3)

# Clean up any layers that might already exist
M.layers.annotation.clear_annotations()
for l in M.layers:
    M.remove_layer(l)
    
v = VectorData('data/states_20m')
M.add_layer(v, colors=['red', 'white', 'blue'])

display(Image(EXPECTED, format="png"))

In [ ]:
EXPECTED="https://data.kitware.com/api/v1/item/589b42e38d777f07219fcc3b/download"
# Set the center of the map to the location the data
M.set_center(-98.58, 39.83, 3)

# Clean up any layers that might already exist
M.layers.annotation.clear_annotations()
for l in M.layers:
    M.remove_layer(l)

cm = plt.get_cmap('YlGnBu')
def color_by_area(feature):
    return cm()
    
v = VectorData('data/states_20m')
M.add_layer(v, colormap=cm)

display(Image(EXPECTED, format="png"))

In [ ]:
EXPECTED="https://data.kitware.com/api/v1/item/589b598e8d777f07219fcc5a/download"
# Set the center of the map to the location the data
M.set_center(-98.58, 39.83, 3)

# Clean up any layers that might already exist
M.layers.annotation.clear_annotations()
for l in M.layers:
    M.remove_layer(l)

v = VectorData('data/states_20m')

# create a custom color function
cm = plt.get_cmap('YlOrRd')
minval = 1e9
maxval = 300e9
def color_by_aland(feature, i):
    aland = feature['properties']['ALAND']
    return cm(float(aland - minval) / (maxval - minval))

M.add_layer(v, colors=color_by_aland)

display(Image(EXPECTED, format="png"))

In [ ]:
EXPECTED="https://data.kitware.com/api/v1/item/589b60e78d777f07219fcc5d/download"
# Set the center of the map to the location the data
M.set_center(-98.58, 39.83, 3)

# Clean up any layers that might already exist
M.layers.annotation.clear_annotations()
for l in M.layers:
    M.remove_layer(l)

v = VectorData('data/ne_50m_populated_places_simple.geojson')

# create a custom color function
cm = plt.get_cmap('YlOrRd')
minval = 0
maxval = 10e6
def color_by_pop(feature, i):
    pop = feature['properties']['pop_max']
    return cm(float(pop - minval) / (maxval - minval))

M.add_layer(v, colors=color_by_pop)

display(Image(EXPECTED, format="png"))

In [ ]:
EXPECTED="https://data.kitware.com/api/v1/item/58a30ca68d777f0721a57c40/download"
# Set the center of the map to the location the data
M.set_center(-98.58, 39.83, 3)

# Clean up any layers that might already exist
M.layers.annotation.clear_annotations()
for l in M.layers:
    M.remove_layer(l)
    
v = VectorData('data/states_20m')
M.add_layer(v, colors=['red', 'white', 'blue'])

# make sure annotations show up above vectors
M.add_annotation('rectangle', [[-126, 23], [-126, 50], [-65, 50], [-65, 23]], {'rgb': 'black'})

display(Image(EXPECTED, format="png"))

In [ ]:
# vector layers don't yet support subsetting, so assert an empty
# list is returned by the `data` iterator
assert list(M.layers.annotation.rectangles[0].data) == []

In [ ]: