当前位置:网站首页>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.

GEE Of DEM Source

stay GEE Every data source in , There are detailed descriptions and code reference examples , For example, in the Netherlands 0.5m Resolution DEM:

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

原网站

版权声明
本文为[Geographical space of ruiduobao]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202211332146022.html