绘制经纬网
主要功能
在每一度的经纬网区域内,绘制60条平均线
代码
// Draws 60 lat/long lines per degree using the pixelLonLat() function.
// Create an image in which the value of each pixel is its
// coordinates in minutes.
var img = ee.Image.pixelLonLat().multiply(60.0);
// Get the decimal part and check if it's less than a small delta.
img = img.subtract(img.floor()).lt(0.05);
// The pixels less than the delta are the grid, in both directions.
var grid = img.select('latitude').or(img.select('longitude'));
// Draw the grid.
Map.setCenter(-122.09228, 37.42330, 12);
Map.addLayer(grid.updateMask(grid), {palette: '008000'}, 'Graticule');
步骤分析
- 生成两波段经纬度信息影像对象
- 对经纬度进行取整,筛选阈值以下部分
- 选择经纬网部分
- 设置地图中心,缩放等级
- 添加图层,只显示经纬网部分
主要方法
- ee.Image.pixelLonLat()
Creates an image with two bands named 'longitude' and 'latitude', containing the longitude and latitude at each pixel, in degrees.
No arguments.
Returns: Image
生成一个两波段影像,分别为经纬度,包含每一个像元的经纬度信息(度形式)
- ee.Image.floor()
Computes the largest integer less than or equal to the input.
Arguments:
this:value (Image):
The image to which the operation is applied.
Returns: Image
求输入影像范围内最大整数,取整功能
网友评论