GEE基础学习——绘制经纬线pixelLonLat

这篇博客展示了如何利用GIS库创建一个图像,其中每个像素的坐标以分钟为单位表示经纬度。通过修改代码中的乘数,可以控制是按度还是按分钟绘制网格,并通过设置颜色和透明度来突出显示经纬线。最终结果是一个清晰的经纬网格,可用于地理数据分析或地图可视化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

按分来绘制全球的经纬网

创建一个图像,其中每个像素的值是其 以分钟为单位的坐标。结果图形如下:

代码展示:

// 使用 pixelLonLat() 函数每度绘制 60 条纬度/经度线。
// 创建一个图像,其中每个像素的值是其 
// 以分钟为单位的坐标。
var img = ee.Image.pixelLonLat().multiply(60.0);

// 获取小数部分并检查它是否小于一个小增量。
img = img.subtract(img.floor()).lt(0.05);

// 两个方向上小于 delta 的像素是的网格。
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');

先展示图形:

If you want to divide the world by degrees, you can use the following code:

//将下面的multiply(60.0)去掉或者改为1.0
var img = ee.Image.pixelLonLat().multiply(1.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');

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

此星光明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值