GEE 底图加载——自定义底图样式加载案例分析(含免费引如多款底图)

2024-03-08 21:12

本文主要是介绍GEE 底图加载——自定义底图样式加载案例分析(含免费引如多款底图),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在本教程中,您将学习如何更改地图对象的选项,以便为底层基础地图定义自己的样式。

地球引擎中的默认地图

地球引擎的基础地图是 Google Map API 中的地图。默认选项包括

  • roadmap,显示默认的路线图视图、
  • 卫星,显示谷歌地球卫星图像、
  • 混合视图,显示普通视图和卫星视图的混合视图,以及
  • 地形:显示基于地形信息的物理地图。

函数

Map.setOptions(mapTypeIdstylestypes)

Modifies the Google Maps basemap. Allows for:

1) Setting the current MapType. 2) Providing custom styles for the basemap (MapTypeStyles). 3) Setting the list of available mapTypesIds for the basemap.

If called with no parameters, resets the map type to the google default.

Returns the map.

修改 Google 地图基图。允许

1) 设置当前地图类型。2) 为基图提供自定义样式(MapTypeStyles)。3) 为基图设置可用的 mapTypesIds 列表。

如果调用时没有参数,则将地图类型重置为谷歌默认类型。

返回地图。

Arguments:

mapTypeId (String, optional):

A mapTypeId to set the basemap to. Can be one of "ROADMAP", "SATELLITE", "HYBRID" or "TERRAIN" to select one of the standard Google Maps API map types, or one of the keys specified in the opt_styles dictionary. If left as null and only 1 style is specified in opt_styles, that style will be used.

styles (Object, optional):

A dictionary of custom MapTypeStyle objects keyed with a name that will appear in the map's Map Type Controls. See: https://developers.google.com/maps/documentation/javascript/reference#MapTypeStyle

types (List<String>, optional):

A list of mapTypeIds to make available. If omitted, but opt_styles is specified, appends all of the style keys to the standard Google Maps API map types.

Returns: ui.Map

更改基本地图样式

我们可以从改变基础地图的风格开始。其中一个简单的方法是反转亮度以获得更暗的背景,就像这样: 

var baseChange = [{featureType: 'all', stylers: [{invert_lightness: true}]}];Map.setOptions('baseChange', {'baseChange': baseChange});

背景暗的情况

背景亮的情况 

主要的造型器选项包括

  • 色调(hue):表示基本颜色
  • 亮度(lightness):表示元素亮度变化的百分比
  • 饱和度(saturation):表示元素基本颜色变化的百分比
  • 伽玛(gamma):元素的伽玛校正(0.01 和 10.0)
  • invert_lightness:反转现有亮度
  • 可见度(visibility):更改元素的可见度选项(开、关或简化)
  • color(color):设置元素的颜色(使用 RGB 十六进制字符串)
  • 权重(weight):以像素为单位设置特征的权重

更改地图元素

谷歌地图应用程序接口(以及延伸的地球引擎)可让您控制大量地图功能和元素。

您可以修改的元素的完整列表可以在谷歌地图文档中找到: https://developers.google.com/maps/documentation/javascript/style-reference

功能的完整列表(也可在上述链接的谷歌地图 API 文档中找到)包括几何图形、标签、图标等。所有造型器选项均可与这些功能配合使用。

例如,要移除图标并自定义路线图样式,可以按如下方式定义样式:

 自己更改代码

// Remove icons.
var iconChange = [{// Change map saturation.stylers: [{gamma: 0.2}]},{// Change label properties.elementType: 'labels',stylers: [{visibility: 'off', color: '#000055'}]},{// Change road properties.featureType: 'road',elementType: 'geometry',stylers: [{visibility: 'off', color: '#000055'}]},{// Change road labels.featureType: 'road',elementType: 'labels',stylers: [{visibility: 'off'}]},{// Change icon properties.elementType: 'labels.icon',stylers: [{visibility: 'off'}]},{// Change POI options.featureType: 'poi',elementType: 'all',stylers: [{visibility: 'off'}]},{featureType: 'administrative',elementType: 'geometry.fill',stylers: [{visibility: 'off'}]},{featureType: 'administrative',elementType: 'geometry.stroke',stylers: [{visibility: 'off'}]}
];// Enhanced road network visualization.
var roadNetwork = [{stylers: [{saturation: -100}]}, {featureType: 'road.highway',elementType: 'geometry.fill',stylers: [{color: '#000055'}, {weight: 2.5}]},{featureType: 'road.highway',elementType: 'geometry.stroke',stylers: [{color: '#000000'}, {weight: 2}]},{featureType: 'road.arterial',elementType: 'geometry',stylers: [{color: '#FF0000'}, {weight: 1.8}]},{featureType: 'road.local',elementType: 'geometry',stylers: [{color: '#00FF55'}, {weight: 1.5}]}
];Map.setOptions('roadNetwork', {iconChange: iconChange, roadNetwork: roadNetwork});

iconChange结果 

 

roadNetwork结果 

 

简化代码:引入格式

还有一种无需调整任何选项即可创建自定义基础地图样式的简便方法:进入 Snazzy Maps,这是一个创建和分享谷歌地图优秀样式的社区项目。他们的网站提供了 JavaScript 代码段,可以从网站上复制这些代码段并粘贴到 Earth Engine 中,从而快速创建备用的基础地图样式。

要应用 Snazzy Maps 样式,可以按以下步骤操作:

引用snazzy代码

var snazzyBlack = [{featureType: 'administrative',elementType: 'all',stylers: [{visibility: 'off'}]},{featureType: 'administrative',elementType: 'labels.text.fill',stylers: [{color: '#444444'}]},{featureType: 'landscape',elementType: 'all',stylers: [{color: '#000000'}, {visibility: 'on'}]},{featureType: 'poi', elementType: 'all', stylers: [{visibility: 'off'}]}, {featureType: 'road',elementType: 'all',stylers: [{saturation: -100}, {lightness: 45}]},{featureType: 'road',elementType: 'geometry.fill',stylers: [{color: '#ffffff'}]},{featureType: 'road',elementType: 'geometry.stroke',stylers: [{color: '#eaeaea'}]},{featureType: 'road', elementType: 'labels', stylers: [{visibility: 'off'}]},{featureType: 'road',elementType: 'labels.text.fill',stylers: [{color: '#dedede'}]},{featureType: 'road',elementType: 'labels.icon',stylers: [{visibility: 'off'}]},{featureType: 'road.highway',elementType: 'all',stylers: [{visibility: 'simplified'}]},{featureType: 'road.arterial',elementType: 'labels.icon',stylers: [{visibility: 'off'}]},{featureType: 'transit', elementType: 'all', stylers: [{visibility: 'off'}]},{featureType: 'water',elementType: 'all',stylers: [{color: '#434343'}, {visibility: 'on'}]}
];var snazzyColor = [{elementType: 'labels', stylers: [{visibility: 'off'}]}, {featureType: 'road',elementType: 'geometry.fill',stylers: [{color: '#0F0919'}]},{featureType: 'water',elementType: 'geometry.fill',stylers: [{color: '#E4F7F7'}]},{elementType: 'geometry.stroke', stylers: [{visibility: 'off'}]}, {featureType: 'poi.park',elementType: 'geometry.fill',stylers: [{color: '#002FA7'}]},{featureType: 'poi.attraction',elementType: 'geometry.fill',stylers: [{color: '#E60003'}]},{featureType: 'landscape',elementType: 'geometry.fill',stylers: [{color: '#FBFCF4'}]},{featureType: 'poi.business',elementType: 'geometry.fill',stylers: [{color: '#FFED00'}]},{featureType: 'poi.government',elementType: 'geometry.fill',stylers: [{color: '#D41C1D'}]},{featureType: 'poi.school',elementType: 'geometry.fill',stylers: [{color: '#BF0000'}]},{featureType: 'transit.line',elementType: 'geometry.fill',stylers: [{saturation: -100}]}
];Map.setOptions('snazzyBlack', {snazzyBlack: snazzyBlack, snazzyColor: snazzyColor});

 snazzyBlack

 snazzyColor 

最后,在为基础地图创建自定义样式时,还可以使用 mapstyle 获得视觉反馈。创建一张地图,复制 JavaScript 代码段并粘贴到 Google 地球引擎 JavaScript 编辑器中。下面的样式就是使用 mapstyle 向导创建的。

免费引用JavaScript Map底图样式链接:

Snazzy Maps - Free Styles for Google Maps

Midnight Commander底图加载代码

var xxx=[{"featureType": "all","elementType": "labels.text.fill","stylers": [{"color": "#ffffff"}]},{"featureType": "all","elementType": "labels.text.stroke","stylers": [{"color": "#000000"},{"lightness": 13}]},{"featureType": "administrative","elementType": "geometry.fill","stylers": [{"color": "#000000"}]},{"featureType": "administrative","elementType": "geometry.stroke","stylers": [{"color": "#144b53"},{"lightness": 14},{"weight": 1.4}]},{"featureType": "landscape","elementType": "all","stylers": [{"color": "#08304b"}]},{"featureType": "poi","elementType": "geometry","stylers": [{"color": "#0c4152"},{"lightness": 5}]},{"featureType": "road.highway","elementType": "geometry.fill","stylers": [{"color": "#000000"}]},{"featureType": "road.highway","elementType": "geometry.stroke","stylers": [{"color": "#0b434f"},{"lightness": 25}]},{"featureType": "road.arterial","elementType": "geometry.fill","stylers": [{"color": "#000000"}]},{"featureType": "road.arterial","elementType": "geometry.stroke","stylers": [{"color": "#0b3d51"},{"lightness": 16}]},{"featureType": "road.local","elementType": "geometry","stylers": [{"color": "#000000"}]},{"featureType": "transit","elementType": "all","stylers": [{"color": "#146474"}]},{"featureType": "water","elementType": "all","stylers": [{"color": "#021019"}]}
]
//Midnight Commander
Map.setOptions('xxx', {xxx: xxx, snazzyColor: snazzyColor});

结果

多有代码


// hue: indicates the basic color
// lightness: indicates percentage change in brightness of an element
// saturation: indicates percentage change in basic color of an element
// gamma: gamma correction of an element (0.01 and 10.0)
// invert_lightness: inverts the existing lightness
// visibility: changes visibility options for an element (on, off, or simplified)
// color: sets the color of an element (using RGB Hex Strings)
// weight: sets the weight of a feature in pixelsvar baseChange = [{featureType: 'all', 
stylers: [{invert_lightness: true,color:'#001155',weight:0.7,hue:'red', lightness:0.6, saturation:0.5, gamma:1.5,visibility:'off'}]}];Map.setOptions('baseChange', {'baseChange': baseChange});// Remove icons.
var iconChange = [{// Change map saturation.stylers: [{gamma: 0.2}]},{// Change label properties.elementType: 'labels',stylers: [{visibility: 'off', color: '#000055'}]},{// Change road properties.featureType: 'road',elementType: 'geometry',stylers: [{visibility: 'off', color: '#000055'}]},{// Change road labels.featureType: 'road',elementType: 'labels',stylers: [{visibility: 'off'}]},{// Change icon properties.elementType: 'labels.icon',stylers: [{visibility: 'off'}]},{// Change POI options.featureType: 'poi',elementType: 'all',stylers: [{visibility: 'off'}]},{featureType: 'administrative',elementType: 'geometry.fill',stylers: [{visibility: 'off'}]},{featureType: 'administrative',elementType: 'geometry.stroke',stylers: [{visibility: 'off'}]}
];// Enhanced road network visualization.
var roadNetwork = [{stylers: [{saturation: -100}]}, {featureType: 'road.highway',elementType: 'geometry.fill',stylers: [{color: '#000055'}, {weight: 2.5}]},{featureType: 'road.highway',elementType: 'geometry.stroke',stylers: [{color: '#000000'}, {weight: 2}]},{featureType: 'road.arterial',elementType: 'geometry',stylers: [{color: '#FF0000'}, {weight: 1.8}]},{featureType: 'road.local',elementType: 'geometry',stylers: [{color: '#00FF55'}, {weight: 1.5}]}
];Map.setOptions('roadNetwork', {iconChange: iconChange, roadNetwork: roadNetwork});var snazzyBlack = [{featureType: 'administrative',elementType: 'all',stylers: [{visibility: 'off'}]},{featureType: 'administrative',elementType: 'labels.text.fill',stylers: [{color: '#444444'}]},{featureType: 'landscape',elementType: 'all',stylers: [{color: '#000000'}, {visibility: 'on'}]},{featureType: 'poi', elementType: 'all', stylers: [{visibility: 'off'}]}, {featureType: 'road',elementType: 'all',stylers: [{saturation: -100}, {lightness: 45}]},{featureType: 'road',elementType: 'geometry.fill',stylers: [{color: '#ffffff'}]},{featureType: 'road',elementType: 'geometry.stroke',stylers: [{color: '#eaeaea'}]},{featureType: 'road', elementType: 'labels', stylers: [{visibility: 'off'}]},{featureType: 'road',elementType: 'labels.text.fill',stylers: [{color: '#dedede'}]},{featureType: 'road',elementType: 'labels.icon',stylers: [{visibility: 'off'}]},{featureType: 'road.highway',elementType: 'all',stylers: [{visibility: 'simplified'}]},{featureType: 'road.arterial',elementType: 'labels.icon',stylers: [{visibility: 'off'}]},{featureType: 'transit', elementType: 'all', stylers: [{visibility: 'off'}]},{featureType: 'water',elementType: 'all',stylers: [{color: '#434343'}, {visibility: 'on'}]}
];var snazzyColor = [{elementType: 'labels', stylers: [{visibility: 'off'}]}, {featureType: 'road',elementType: 'geometry.fill',stylers: [{color: '#0F0919'}]},{featureType: 'water',elementType: 'geometry.fill',stylers: [{color: '#E4F7F7'}]},{elementType: 'geometry.stroke', stylers: [{visibility: 'off'}]}, {featureType: 'poi.park',elementType: 'geometry.fill',stylers: [{color: '#002FA7'}]},{featureType: 'poi.attraction',elementType: 'geometry.fill',stylers: [{color: '#E60003'}]},{featureType: 'landscape',elementType: 'geometry.fill',stylers: [{color: '#FBFCF4'}]},{featureType: 'poi.business',elementType: 'geometry.fill',stylers: [{color: '#FFED00'}]},{featureType: 'poi.government',elementType: 'geometry.fill',stylers: [{color: '#D41C1D'}]},{featureType: 'poi.school',elementType: 'geometry.fill',stylers: [{color: '#BF0000'}]},{featureType: 'transit.line',elementType: 'geometry.fill',stylers: [{saturation: -100}]}
];Map.setOptions('snazzyBlack', {snazzyBlack: snazzyBlack, snazzyColor: snazzyColor});var xxx=[{"featureType": "all","elementType": "labels.text.fill","stylers": [{"color": "#ffffff"}]},{"featureType": "all","elementType": "labels.text.stroke","stylers": [{"color": "#000000"},{"lightness": 13}]},{"featureType": "administrative","elementType": "geometry.fill","stylers": [{"color": "#000000"}]},{"featureType": "administrative","elementType": "geometry.stroke","stylers": [{"color": "#144b53"},{"lightness": 14},{"weight": 1.4}]},{"featureType": "landscape","elementType": "all","stylers": [{"color": "#08304b"}]},{"featureType": "poi","elementType": "geometry","stylers": [{"color": "#0c4152"},{"lightness": 5}]},{"featureType": "road.highway","elementType": "geometry.fill","stylers": [{"color": "#000000"}]},{"featureType": "road.highway","elementType": "geometry.stroke","stylers": [{"color": "#0b434f"},{"lightness": 25}]},{"featureType": "road.arterial","elementType": "geometry.fill","stylers": [{"color": "#000000"}]},{"featureType": "road.arterial","elementType": "geometry.stroke","stylers": [{"color": "#0b3d51"},{"lightness": 16}]},{"featureType": "road.local","elementType": "geometry","stylers": [{"color": "#000000"}]},{"featureType": "transit","elementType": "all","stylers": [{"color": "#146474"}]},{"featureType": "water","elementType": "all","stylers": [{"color": "#021019"}]}
]
//Midnight Commander
Map.setOptions('xxx', {xxx: xxx, snazzyColor: snazzyColor});

 

这篇关于GEE 底图加载——自定义底图样式加载案例分析(含免费引如多款底图)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/788418

相关文章

MySQL中的LENGTH()函数用法详解与实例分析

《MySQL中的LENGTH()函数用法详解与实例分析》MySQLLENGTH()函数用于计算字符串的字节长度,区别于CHAR_LENGTH()的字符长度,适用于多字节字符集(如UTF-8)的数据验证... 目录1. LENGTH()函数的基本语法2. LENGTH()函数的返回值2.1 示例1:计算字符串

SpringBoot+EasyExcel实现自定义复杂样式导入导出

《SpringBoot+EasyExcel实现自定义复杂样式导入导出》这篇文章主要为大家详细介绍了SpringBoot如何结果EasyExcel实现自定义复杂样式导入导出功能,文中的示例代码讲解详细,... 目录安装处理自定义导出复杂场景1、列不固定,动态列2、动态下拉3、自定义锁定行/列,添加密码4、合并

Python通用唯一标识符模块uuid使用案例详解

《Python通用唯一标识符模块uuid使用案例详解》Pythonuuid模块用于生成128位全局唯一标识符,支持UUID1-5版本,适用于分布式系统、数据库主键等场景,需注意隐私、碰撞概率及存储优... 目录简介核心功能1. UUID版本2. UUID属性3. 命名空间使用场景1. 生成唯一标识符2. 数

浅析Spring如何控制Bean的加载顺序

《浅析Spring如何控制Bean的加载顺序》在大多数情况下,我们不需要手动控制Bean的加载顺序,因为Spring的IoC容器足够智能,但在某些特殊场景下,这种隐式的依赖关系可能不存在,下面我们就来... 目录核心原则:依赖驱动加载手动控制 Bean 加载顺序的方法方法 1:使用@DependsOn(最直

Android kotlin中 Channel 和 Flow 的区别和选择使用场景分析

《Androidkotlin中Channel和Flow的区别和选择使用场景分析》Kotlin协程中,Flow是冷数据流,按需触发,适合响应式数据处理;Channel是热数据流,持续发送,支持... 目录一、基本概念界定FlowChannel二、核心特性对比数据生产触发条件生产与消费的关系背压处理机制生命周期

Android ClassLoader加载机制详解

《AndroidClassLoader加载机制详解》Android的ClassLoader负责加载.dex文件,基于双亲委派模型,支持热修复和插件化,需注意类冲突、内存泄漏和兼容性问题,本文给大家介... 目录一、ClassLoader概述1.1 类加载的基本概念1.2 android与Java Class

PostgreSQL的扩展dict_int应用案例解析

《PostgreSQL的扩展dict_int应用案例解析》dict_int扩展为PostgreSQL提供了专业的整数文本处理能力,特别适合需要精确处理数字内容的搜索场景,本文给大家介绍PostgreS... 目录PostgreSQL的扩展dict_int一、扩展概述二、核心功能三、安装与启用四、字典配置方法

怎样通过分析GC日志来定位Java进程的内存问题

《怎样通过分析GC日志来定位Java进程的内存问题》:本文主要介绍怎样通过分析GC日志来定位Java进程的内存问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、GC 日志基础配置1. 启用详细 GC 日志2. 不同收集器的日志格式二、关键指标与分析维度1.

Python中re模块结合正则表达式的实际应用案例

《Python中re模块结合正则表达式的实际应用案例》Python中的re模块是用于处理正则表达式的强大工具,正则表达式是一种用来匹配字符串的模式,它可以在文本中搜索和匹配特定的字符串模式,这篇文章主... 目录前言re模块常用函数一、查看文本中是否包含 A 或 B 字符串二、替换多个关键词为统一格式三、提

MySQL中的表连接原理分析

《MySQL中的表连接原理分析》:本文主要介绍MySQL中的表连接原理分析,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、背景2、环境3、表连接原理【1】驱动表和被驱动表【2】内连接【3】外连接【4编程】嵌套循环连接【5】join buffer4、总结1、背景