当前位置:网站首页>Drawing DEM with GEE gracefully
Drawing DEM with GEE gracefully
2022-06-24 19:22:00 【Geographical space of ruiduobao】
About
I read a high-quality article yesterday python Draw topographic map blog . Is like , It occurred to me GEE(Google earth engine) There are many data sources 、 Fast calculation 、 The characteristic of many calculation operators , Use GEE It should not be inferior to python.
Production process
Use GEE draw DEM Altogether 3 Step , One of the most important is the use of color palette .
(1)DEM data source
GEE Of DEM There are a lot of data , Readers can choose the appropriate data source according to their own needs . The study area is large , Lower resolution data can be selected , If the study area is small , Try to use high resolution DEM.
stay GEE Every data source in , There are detailed descriptions and code reference examples , For example, in the Netherlands 0.5m Resolution DEM:
Considering that the test area is my hometown Sichuan Province , Here we use the global 30m The resolution of the NASA DEM.
// Introduce data sources The research area chooses my hometown, Sichuan Province
var dataset = ee.Image('NASA/NASADEM_HGT/001');
var elevation = dataset.select('elevation').clip(ROI);
// Set visualization parameters
var elevationVis = {
min: 0,
max: 8000,
};
// visualization
Map.addLayer(elevation, elevationVis, 'Elevation');
Map.centerObject(ROI, 7);
(2) Color scheme
After the data is loaded , The color of the data is not good-looking , This is the time palette . There are several ways , One is in GEE Manual adjustment in DEM Show :
Another is that you can refer to other people's already set color palette , Call directly , Here I recommend one GitHub Warehouse ee-palettes(https://github.com/gee-community/ee-palettes):
The warehouse collects nearly 200 color schemes , stay GEE Can be called directly :
Call this repository , Just introduce the function library , then new A palette , And fill the color scheme into the map loading function , Pay attention to setting the maximum and minimum values . Then try one by one against the color table , Find the most suitable color scheme .
// Call the palette already configured in the warehouse
var palettes = require('users/gena/packages:palettes');
var palette_bamako = palettes.crameri.bamako[10,25,50];
Map.addLayer(elevation, {
min:0, max:8000, palette: palette_bamako}, 'crameri.bamako');
var palette_rainbow = palettes.kovesi.rainbow_bgyr_35_85_c72[7];
Map.addLayer(elevation, {
min:0, max:8000, palette: palette_rainbow}, 'palette_rainbow');
var palette_misc = palettes.misc.jet[7];
Map.addLayer(elevation, {
min:0, max:8000, palette: palette_misc}, 'palette_misc');
var palette_diverging = palettes.kovesi.diverging_linear_bjy_30_90_c45[7];
Map.addLayer(elevation, {
min:0, max:8000, palette: palette_diverging}, 'palette_diverging');
In the process of color matching , You can also note that the maximum and minimum values of the palette are different from each other DEM Show the impact . The highest altitude in Sichuan Province is 7556 rice , The lowest altitude is 188 rice . However, this does not mean that our color range should follow the maximum and minimum values , Because in color matching, if the pixel value is greater than max value , Then the color is the rightmost , The value will be adjusted automatically , If we can find the best range , The internal pixels are caused by height differences The contrast is more obvious , let me put it another way , The display effect is better when using most range of values .
According to the DEM Value distribution histogram , I made the following comparisons :
// Range comparison
//0-8000m
var palette_rainbow1 = palettes.kovesi.rainbow_bgyr_35_85_c72[7];
Map.addLayer(elevation, {
min:0, max:8000, palette: palette_rainbow1}, 'palette_rainbow1');
// Maximum and minimum
var palette_rainbow2 = palettes.kovesi.rainbow_bgyr_35_85_c72[7];
Map.addLayer(elevation, {
min:188, max:7556, palette: palette_rainbow2}, 'palette_rainbow2');
// The maximum and minimum values of the horizontal axis of the histogram
var palette_rainbow3 = palettes.kovesi.rainbow_bgyr_35_85_c72[7];
Map.addLayer(elevation, {
min:451, max:4525, palette: palette_rainbow3}, 'palette_rainbow3');
// The minimum value of the horizontal axis of the histogram is the same as 6000
var palette_rainbow4 = palettes.kovesi.rainbow_bgyr_35_85_c72[7];
Map.addLayer(elevation, {
min:451, max:6000, palette: palette_rainbow4}, 'palette_rainbow4');
How to choose the right Value range of palette , It is also an elegant drawing DEM An important factor in .
(3) Mountain shadow ;
A better DEM data source 、 palette 、 After value range , We can add mountain shadows to enhance DEM Display effect of . function ee.Terrain.hillshade(input,azimuth, elevation) Is the operator that generates mountain shadow ,input by DEM,azimuth It's azimuth ,elevation Is the height angle .
A bearing is the angular direction of the sun , Is based on the north direction in 0 To 360 Measured clockwise within degrees ,90º The azimuth of is East . Height refers to the angle or slope of the light source above the horizon . The unit of height is degrees , The scope is 0( On the horizon ) To 90( On the head ) Between . We need to pay attention to hillshade The value range of is 0-255.
// Mountain shadow
var palette_hillshade = palettes.crameri.bamako[10,25,50];
var exaggeration = 20;
var hillshade = ee.Terrain.hillshade(elevation.multiply(exaggeration),270,45);
Map.addLayer(hillshade, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade');
azimuth
There are azimuth angles that affect the display effect of mountain shadow :
// Different azimuth angles
var palette_hillshade = palettes.crameri.bamako[10,25,50];
var exaggeration = 20;
var hillshade_45 = ee.Terrain.hillshade(elevation.multiply(exaggeration),45,15);
Map.addLayer(hillshade_45, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade_45');
var hillshade_135 = ee.Terrain.hillshade(elevation.multiply(exaggeration),135,15);
Map.addLayer(hillshade_135, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade_135');
var hillshade_225 = ee.Terrain.hillshade(elevation.multiply(exaggeration),225,15);
Map.addLayer(hillshade_225, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade_225');
var hillshade_315 = ee.Terrain.hillshade(elevation.multiply(exaggeration),315,15);
Map.addLayer(hillshade_315, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade_315');
GEE The default bearing for is 270º , The author can choose an appropriate azimuth according to his own needs .
Height angle
Different height angles will also affect the display effect of mountain shadow :
// Different height angles
var palette_hillshade = palettes.crameri.bamako[10,25,50];
var exaggeration = 20;
var hillshade_15 = ee.Terrain.hillshade(elevation.multiply(exaggeration),270,15);
Map.addLayer(hillshade_15, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade_15');
var hillshade_30 = ee.Terrain.hillshade(elevation.multiply(exaggeration),270,30);
Map.addLayer(hillshade_30, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade_30');
var hillshade_45 = ee.Terrain.hillshade(elevation.multiply(exaggeration),270,45);
Map.addLayer(hillshade_45, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade_45');
var hillshade_60 = ee.Terrain.hillshade(elevation.multiply(exaggeration),270,60);
Map.addLayer(hillshade_60, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade_60');
var hillshade_75 = ee.Terrain.hillshade(elevation.multiply(exaggeration),270,75);
Map.addLayer(hillshade_75, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade_75');
var hillshade_90 = ee.Terrain.hillshade(elevation.multiply(exaggeration),270,90);
Map.addLayer(hillshade_90, {
min: 0, max: 255, palette: palette_hillshade}, 'palette_hillshade_90');
Generally speaking , The smaller the height angle , The stronger the mountain shadow effect , The height angle is gee Default is 45°.
Code link
https://code.earthengine.google.com/2e947952a68cb01eb63a247ec4424936
At the end
Summarize the following , Use elegantly GEE draw DEM:
First of all Select the data source , Select high-resolution for small study area DEM, Large study area can choose low resolution DEM;
The second is to choose well palette , Third party libraries are recommended here ee-palettes, Then, notice the maximum value range of the palette ;
The second is making Mountain shadow , Pay attention to selecting the appropriate sun altitude and azimuth .
This article just provides a production idea , Because the author's aesthetic level is limited , Readers don't have to follow my color scheme to make topographic maps , How to look how to come .
Reference resources
Clarmy Squeak . How to use Python Draw a cool three-dimensional topographic map
边栏推荐
- How to use JWT authentication in thinkphp6
- Volcano成Spark默认batch调度器
- Network security review office starts network security review on HowNet
- Why are life science enterprises on the cloud in succession?
- 使用阿里云RDS for SQL Server性能洞察优化数据库负载-初识性能洞察
- Will the CDC read out of order when I use SQL
- 智能合约安全审计入门篇 —— delegatecall (2)
- AI时代生物隐私如何保护?马德里自治大学最新《生物特征识别中的隐私增强技术》综述,全面详述生物隐私增强技术
- Application scenarios of channel of go question bank · 11
- SaltStack State状态文件配置实例
猜你喜欢
Freeswitch使用originate转dialplan
程序员大部分时间不是写代码,而是。。。
Technology implementation | Apache Doris cold and hot data storage (I)
Php OSS file read and write file, workerman Generate Temporary file and Output Browser Download
Volcano becomes spark default batch scheduler
Apifox与其他接口开发工具的博弈
Starring V6 platform development take out point process
全链路业务追踪落地实践方案
Module V
程序员如何做自媒体?
随机推荐
ArrayList源码解析
Tkde2022: Dialogue recommendation system based on knowledge enhanced sampling
starring V6平台开发接出点流程
Mqtt protocol usage of LabVIEW
企业网络管理员必备的故障处理系统
This is not safe
How to deal with the problem that the Flink CDC reads MySQL in full and always reports this error
对国产数据库厂商提几个关于SQL引擎的小需求
建立自己的网站(8)
Would you like to ask whether the same multiple tasks of the PgSQL CDC account will have an impact? I now have only one of the three tasks
The group offsets of the Kafka of the Flink SQL. If the specified groupid is not mentioned
小白请教下各位大佬,cdc抽取mysql binlog是严格顺序的吗
The script implements the automated deployment of raid0
Example analysis of corrplot related heat map beautification in R language
60 divine vs Code plug-ins!!
Necessary fault handling system for enterprise network administrator
Sr-gnn shift robot gnns: overlapping the limitations of localized graph training data
Volcano成Spark默认batch调度器
Php OSS file read and write file, workerman Generate Temporary file and Output Browser Download
Volcano成Spark默認batch調度器