gee python:利用核函数对影像进行平滑处理和边缘提取分析

简介: gee python:利用核函数对影像进行平滑处理和边缘提取分析

安装地球引擎API和geemap

安装地球引擎的Python API和geemap。geemap Python包是建立在ipyleaflet和folium包之上的,它实现了几个与地球引擎数据层交互的方法,比如Map.addLayer()、Map.setCenter()和Map.centerObject()。下面的脚本检查geemap包是否已经安装。如果没有,它将安装geemap,它会自动安装其依赖项,包括earthengine-api、folium和ipyleaflet。

# Installs geemap package
import subprocess
try:
    import geemap
except ImportError:
    print('Installing geemap ...')
    subprocess.check_call(["python", '-m', 'pip', 'install', 'geemap'])
import ee
import geemap

使用的函数:

**ee.Kernel.square(*args, kwargs)

Generates a square-shaped boolean kernel.这里使用这个核函数创建一个布尔类型的内核。

参数类型的设定中我们可以使用半径和单位进行设定。

Args:

radius: The radius of the kernel to generate.

units: The system of measurement for the kernel (‘pixels’ or

‘meters’). If the kernel is specified in meters, it will

resize when the zoom-level is changed.

normalize: Normalize the kernel values to sum to 1.

magnitude: Scale each value by this amount.

**image.convolve(*args, kwargs)

Convolves each band of an image with the given kernel.

将每一个指定的影像波段转化为给定的核函数,通过与 Boxcar 内核卷积来平滑图像。

Args:

image: The image to convolve.

kernel: The kernel to convolve with.

**ee.Kernel.laplacian8(*args, kwargs)

Generates a 3x3 Laplacian-8 edge-detection kernel.

Args:

magnitude: Scale each value by this amount.

normalize: Normalize the kernel values to sum to 1

生成 3x3 Laplacian-8 边缘检测内核。

参数:

大小:按此量缩放每个值。

标准化:将核值标准化为总和为 1

# Add Earth Engine dataset
# Load and display an image.
image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318')
Map.setCenter(-121.9785, 37.8694, 11)
Map.addLayer(image, {'bands': ['B5', 'B4', 'B3'], 'max': 0.5}, 'input image')
# Define a boxcar or low-pass kernel.
# boxcar = ee.Kernel.square({
#   'radius': 7, 'units': 'pixels', 'normalize': True
# })
boxcar = ee.Kernel.square(7, 'pixels', True)
# Smooth the image by convolving with the boxcar kernel.
smooth = image.convolve(boxcar)
Map.addLayer(smooth, {'bands': ['B5', 'B4', 'B3'], 'max': 0.5}, 'smoothed')
# Define a Laplacian, or edge-detection kernel.
laplacian = ee.Kernel.laplacian8(1, False)
# Apply the edge-detection kernel.
edgy = image.convolve(laplacian)
Map.addLayer(edgy,
             {'bands': ['B5', 'B4', 'B3'], 'max': 0.5},
             'edges')

相关文章
|
1天前
|
数据采集 数据可视化 Python
Python分析香港26281套在售二手房数据
Python分析香港26281套在售二手房数据
|
4天前
|
数据采集 人工智能 数据挖掘
「一行分析」利用12000条招聘数据分析Python学习方向和就业方向
「一行分析」利用12000条招聘数据分析Python学习方向和就业方向
|
4天前
|
JSON JavaScript 数据格式
利用 python 分析基金,合理分析数据让赚钱赢在起跑线!(1)
利用 python 分析基金,合理分析数据让赚钱赢在起跑线!(1)
|
6天前
|
存储 数据挖掘 数据处理
使用Python将数据表中的浮点数据转换为整数:详细教程与案例分析
使用Python将数据表中的浮点数据转换为整数:详细教程与案例分析
9 2
|
6天前
|
数据采集 算法 数据可视化
python实现时序平滑算法SG滤波器
python实现时序平滑算法SG滤波器
|
6天前
|
语音技术 开发者 Python
python之pyAudioAnalysis:音频特征提取分析文档示例详解
python之pyAudioAnalysis:音频特征提取分析文档示例详解
20 0
|
6天前
|
数据可视化 大数据 Python
python大数据分析处理
python大数据分析处理
14 0
|
6天前
|
机器学习/深度学习 人工智能 大数据
AI时代Python金融大数据分析实战:ChatGPT让金融大数据分析插上翅膀
AI时代Python金融大数据分析实战:ChatGPT让金融大数据分析插上翅膀
|
1天前
|
数据采集 算法 Python
2024年Python最全python基础入门:高阶函数,小米面试编程题
2024年Python最全python基础入门:高阶函数,小米面试编程题
|
1天前
|
数据采集 人工智能 前端开发
干货满满,转行逆袭,0编程基础学Python拿高薪offer如何做?都在这里!
干货满满,转行逆袭,0编程基础学Python拿高薪offer如何做?都在这里!