F60e Checkpoint
Import libraries¶
In [ ]:
Copied!
import ee
import geemap
import ee
import geemap
Create an interactive map¶
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
Map = geemap.Map(center=[40, -100], zoom=4)
Add Earth Engine Python script¶
In [ ]:
Copied!
# Add Earth Engine dataset
image = ee.Image("USGS/SRTMGL1_003")
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Chapter: F6.0 Advanced Raster Visualization
# Checkpoint: F60e
# Authors: Gennadii Donchyts, Fedor Baart
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# *
# Draws a string as a raster image at a given point.
#
# @param {string} str - string to draw
# @param {ee.Geometry} point - location the the string will be drawn
# @param {{string, Object}} options - optional properties used to style text
#
# The options dictionary may include one or more of the following:
# fontSize - 16|18|24|32 - the size of the font (default: 16)
# fontType - Arial|Consolas - the type of the font (default: Arial)
# alignX - left|center|right (default: left)
# alignY - top|center|bottom (default: top)
# textColor - text color string (default: ffffff - white)
# textOpacity - 0-1, opacity of the text (default: 0.9)
# textWidth - width of the text (default: 1)
# outlineColor - text outline color string (default: 000000 - black)
# outlineOpacity - 0-1, opacity of the text outline (default: 0.4)
# outlineWidth - width of the text outlines (default: 0)
#
# Include the text package.
text = require("users/gena/packages:text")
# Configure map (change center and map type).
Map.setCenter(0, 0, 10)
Map.setOptions("HYBRID")
# Draw text string and add to map.
pt = Map.getCenter()
scale = Map.getScale()
image = text.draw("Hello World!", pt, scale)
# -----------------------------------------------------------------------
# CHECKPOINT
# -----------------------------------------------------------------------
image = text.draw(
"Hello World!",
pt,
scale,
{
"fontSize": 32,
"fontType": "Consolas",
"textColor": "black",
"outlineColor": "white",
"outlineWidth": 1,
"outlineOpacity": 0.8,
},
)
# Add the text image to the map.
Map.addLayer(image)
# -----------------------------------------------------------------------
# CHECKPOINT
# -----------------------------------------------------------------------
# Add Earth Engine dataset
image = ee.Image("USGS/SRTMGL1_003")
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Chapter: F6.0 Advanced Raster Visualization
# Checkpoint: F60e
# Authors: Gennadii Donchyts, Fedor Baart
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# *
# Draws a string as a raster image at a given point.
#
# @param {string} str - string to draw
# @param {ee.Geometry} point - location the the string will be drawn
# @param {{string, Object}} options - optional properties used to style text
#
# The options dictionary may include one or more of the following:
# fontSize - 16|18|24|32 - the size of the font (default: 16)
# fontType - Arial|Consolas - the type of the font (default: Arial)
# alignX - left|center|right (default: left)
# alignY - top|center|bottom (default: top)
# textColor - text color string (default: ffffff - white)
# textOpacity - 0-1, opacity of the text (default: 0.9)
# textWidth - width of the text (default: 1)
# outlineColor - text outline color string (default: 000000 - black)
# outlineOpacity - 0-1, opacity of the text outline (default: 0.4)
# outlineWidth - width of the text outlines (default: 0)
#
# Include the text package.
text = require("users/gena/packages:text")
# Configure map (change center and map type).
Map.setCenter(0, 0, 10)
Map.setOptions("HYBRID")
# Draw text string and add to map.
pt = Map.getCenter()
scale = Map.getScale()
image = text.draw("Hello World!", pt, scale)
# -----------------------------------------------------------------------
# CHECKPOINT
# -----------------------------------------------------------------------
image = text.draw(
"Hello World!",
pt,
scale,
{
"fontSize": 32,
"fontType": "Consolas",
"textColor": "black",
"outlineColor": "white",
"outlineWidth": 1,
"outlineOpacity": 0.8,
},
)
# Add the text image to the map.
Map.addLayer(image)
# -----------------------------------------------------------------------
# CHECKPOINT
# -----------------------------------------------------------------------
Display the interactive map¶
In [ ]:
Copied!
Map
Map