ee.Kernel.rotate

Tạo một Kernel.

Cách sử dụngGiá trị trả về
Kernel.rotate(rotations)Kernel
Đối sốLoạiThông tin chi tiết
this: kernelKernelNhân cần xoay.
rotationsSố nguyênSố lần xoay 90 độ cần thực hiện. Số âm xoay ngược chiều kim đồng hồ.

Ví dụ

Trình soạn thảo mã (JavaScript)

// A kernel to be rotated.
var sobelKernel = ee.Kernel.sobel();
print(sobelKernel);

/**
 * Output weights matrix
 *
 * [-1, 0, 1]
 * [-2, 0, 2]
 * [-1, 0, 1]
 */

print('One 90 degree clockwise rotation', sobelKernel.rotate(1));

/**
 * [-1, -2, -1]
 * [ 0,  0,  0]
 * [ 1,  2,  1]
 */

print('Two 90 degree counterclockwise rotations', sobelKernel.rotate(-2));

/**
 * [1, 0, -1]
 * [2, 0, -2]
 * [1, 0, -1]
 */

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho quá trình phát triển tương tác.

import ee
import geemap.core as geemap

Colab (Python)

from pprint import pprint

# A kernel to be rotated.
sobel_kernel = ee.Kernel.sobel()
pprint(sobel_kernel.getInfo())

#  Output weights matrix

#  [-1, 0, 1]
#  [-2, 0, 2]
#  [-1, 0, 1]

print('One 90 degree clockwise rotation:')
pprint(sobel_kernel.rotate(1).getInfo())

#  [-1, -2, -1]
#  [ 0,  0,  0]
#  [ 1,  2,  1]

print('Two 90 degree counterclockwise rotations:')
pprint(sobel_kernel.rotate(-2).getInfo())

#  [1, 0, -1]
#  [2, 0, -2]
#  [1, 0, -1]