73 transect
In [1]:
Copied!
import ee
import geemap
from bqplot import pyplot as plt
import ee
import geemap
from bqplot import pyplot as plt
In [2]:
Copied!
Map = geemap.Map()
Map.add_basemap("TERRAIN")
Map
Map = geemap.Map()
Map.add_basemap("TERRAIN")
Map
Out[2]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [3]:
Copied!
image = ee.Image('USGS/SRTMGL1_003')
vis_params = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],
}
Map.addLayer(image, vis_params, 'SRTM DEM', True, 0.5)
image = ee.Image('USGS/SRTMGL1_003')
vis_params = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],
}
Map.addLayer(image, vis_params, 'SRTM DEM', True, 0.5)
In [4]:
Copied!
# Use the drawing tool to draw any line on the map.
line = Map.user_roi
if line is None:
line = ee.Geometry.LineString(
[[-120.223279, 36.314849], [-118.926969, 36.712192], [-117.202217, 36.756215]]
)
Map.addLayer(line, {}, "ROI")
Map.centerObject(line)
# Use the drawing tool to draw any line on the map.
line = Map.user_roi
if line is None:
line = ee.Geometry.LineString(
[[-120.223279, 36.314849], [-118.926969, 36.712192], [-117.202217, 36.756215]]
)
Map.addLayer(line, {}, "ROI")
Map.centerObject(line)
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [4], in <cell line: 2>() 1 # Use the drawing tool to draw any line on the map. ----> 2 line = Map.user_roi 3 if line is None: 4 line = ee.Geometry.LineString( 5 [[-120.223279, 36.314849], [-118.926969, 36.712192], [-117.202217, 36.756215]] 6 ) AttributeError: 'Map' object has no attribute 'user_roi'
In [5]:
Copied!
line.getInfo()
line.getInfo()
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Input In [5], in <cell line: 1>() ----> 1 line.getInfo() NameError: name 'line' is not defined
In [6]:
Copied!
reducer = 'mean' # Any ee.Reducer, e.g., mean, median, min, max, stdDev
transect = geemap.extract_transect(
image, line, n_segments=100, reducer=reducer, to_pandas=True
)
reducer = 'mean' # Any ee.Reducer, e.g., mean, median, min, max, stdDev
transect = geemap.extract_transect(
image, line, n_segments=100, reducer=reducer, to_pandas=True
)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Input In [6], in <cell line: 2>() 1 reducer = 'mean' # Any ee.Reducer, e.g., mean, median, min, max, stdDev 2 transect = geemap.extract_transect( ----> 3 image, line, n_segments=100, reducer=reducer, to_pandas=True 4 ) NameError: name 'line' is not defined
In [7]:
Copied!
transect
transect
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Input In [7], in <cell line: 1>() ----> 1 transect NameError: name 'transect' is not defined
In [8]:
Copied!
fig = plt.figure()
plt.plot(transect['distance'], transect[reducer])
plt.xlabel('Distance')
plt.ylabel("Elevation")
plt.show()
fig = plt.figure()
plt.plot(transect['distance'], transect[reducer])
plt.xlabel('Distance')
plt.ylabel("Elevation")
plt.show()
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Input In [8], in <cell line: 2>() 1 fig = plt.figure() ----> 2 plt.plot(transect['distance'], transect[reducer]) 3 plt.xlabel('Distance') 4 plt.ylabel("Elevation") NameError: name 'transect' is not defined
Last update:
2022-03-14