15_geemap学习笔记 | js转py

15 convert js to py

import ee
import geemap
geemap.set_proxy(10809)
geemap.show_youtube('nAzZjKKd4w0')

在这里插入图片描述

实例1

# 实例1

js_snippet = """
// Load an image.
var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318');

// Define the visualization parameters.
var vizParams = {
  bands: ['B5', 'B4', 'B3'],
  min: 0,
  max: 0.5,
  gamma: [0.95, 1.1, 1]
};

// Center the map and display the image.
Map.setCenter(-122.1899, 37.5010, 10); // San Francisco Bay
Map.addLayer(image, vizParams, 'false color composite');

"""
geemap.js_snippet_to_py(js_snippet, add_new_cell=True, import_ee=True, import_geemap=  True, show_map= True)

#输出
# import ee
# import geemap

# Map = geemap.Map()

# # Load an image.
# image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318')

# # Define the visualization parameters.
# vizParams = {
#   'bands': ['B5', 'B4', 'B3'],
#   'min': 0,
#   'max': 0.5,
#   'gamma': [0.95, 1.1, 1]
# }

# # Center the map and display the image.
# Map.setCenter(-122.1899, 37.5010, 10); # San Francisco Bay
# Map.addLayer(image, vizParams, 'False color composite')
# Map

在这里插入图片描述

实例2

# 实例2
js_snippet = """

// Load an image.
var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318');

// Create an NDWI image, define visualization parameters and display.
var ndwi = image.normalizedDifference(['B3', 'B5']);
var ndwiViz = {min: 0.5, max: 1, palette: ['00FFFF', '0000FF']};
Map.addLayer(ndwi, ndwiViz, 'NDWI', false);

"""
geemap.js_snippet_to_py(js_snippet)


# import ee
# import geemap

# Map = geemap.Map()

# # Load an image.
# image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318')

# # Create an NDWI image, define visualization parameters and display.
# ndwi = image.normalizedDifference(['B3', 'B5'])
# ndwiViz = {'min': 0.5, 'max': 1, 'palette': ['00FFFF', '0000FF']}
# Map.addLayer(ndwi, ndwiViz, 'NDWI', False)
# Map

在这里插入图片描述

实例3

# 实例3
js_snippet = """

// Load 2012 MODIS land cover and select the IGBP classification.
var cover = ee.Image('MODIS/051/MCD12Q1/2012_01_01')
  .select('Land_Cover_Type_1');

// Define a palette for the 18 distinct land cover classes.
var igbpPalette = [
  'aec3d4', // water
  '152106', '225129', '369b47', '30eb5b', '387242', // forest
  '6a2325', 'c3aa69', 'b76031', 'd9903d', '91af40',  // shrub, grass
  '111149', // wetlands
  'cdb33b', // croplands
  'cc0013', // urban
  '33280d', // crop mosaic
  'd7cdcc', // snow and ice
  'f7e084', // barren
  '6f6f6f'  // tundra
];

// Specify the min and max labels and the color palette matching the labels.
Map.setCenter(-99.229, 40.413, 5);
Map.addLayer(cover,
             {min: 0, max: 17, palette: igbpPalette},
             'IGBP classification');

"""
geemap.js_snippet_to_py(js_snippet)

# import ee
# import geemap

# Map = geemap.Map()

# # Load 2012 MODIS land cover and select the IGBP classification.
# cover = ee.Image('MODIS/051/MCD12Q1/2012_01_01') .select('Land_Cover_Type_1')

# # Define a palette for the 18 distinct land cover classes.
# igbpPalette = [
#   'aec3d4', # water
#   '152106', '225129', '369b47', '30eb5b', '387242', # forest
#   '6a2325', 'c3aa69', 'b76031', 'd9903d', '91af40',  # shrub, grass
#   '111149', # wetlands
#   'cdb33b', # croplands
#   'cc0013', # urban
#   '33280d', # crop mosaic
#   'd7cdcc', # snow and ice
#   'f7e084', # barren
#   '6f6f6f'  # tundra
# ]

# # Specify the min and max labels and the color palette matching the labels.
# Map.setCenter(-99.229, 40.413, 5)
# Map.addLayer(cover,
#              {'min': 0, 'max': 17, 'palette': igbpPalette},
#              'IGBP classification')
# Map

在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值