Initialize Earth Engine


In [1]:
import ee
ee.Initialize()

Python Package Imports


In [2]:
from IPython.display import Image
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
from IPython.display import HTML


:0: FutureWarning: IPython widgets are experimental and may change in the future.

Code


In [3]:
image = ee.Image('LT5_L1T_8DAY_EVI/20110618')

# Define the region of interest
point = ee.Geometry.Point(-101.05259, 37.93418)
region = point.buffer(10000).bounds().getInfo()['coordinates']

canny = ee.Algorithms.CannyEdgeDetector(image, 0.7)

# Mask the image with itself to get rid of 0 pixels.
canny = canny.mask(canny)

combined = ee.ImageCollection([
        image.visualize(min=0, max=1, forceRgbOutput=True),
        canny.visualize(min=0, max=1, palette=["FF0000"], forceRgbOutput=True)
    ]).mosaic()
url = combined.getThumbUrl({'region':region})
print(url)
display(Image(url=url))


https://earthengine.googleapis.com//api/thumb?thumbid=b8897962c07b622881ae5482b7ca0b3f&token=d21946e0a825f453d7904845e77a89ad

In [4]:
def edit_image(image, threshold=0.25):
    canny = ee.Algorithms.CannyEdgeDetector(image, threshold)

    canny = canny.mask(canny)

    combined = ee.ImageCollection([
        #image.visualize(min=0, max=1, forceRgbOutput=True),
        canny.visualize(min=0, max=1, palette=["FF0000"], forceRgbOutput=True)
    ]).mosaic()
    new_image = Image(url=combined.getThumbUrl({'region':region}))
    display(new_image)
    return new_image

An interactive version


In [5]:
slider = interactive(edit_image, image=fixed(image), threshold=(0.0,1.5,0.25))
display(slider)



In [ ]: