本文主要是介绍11_geemap学习笔记 | 导出影像,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
导出图像
- Download an ee.Image
- Download an ee.ImageCollection
- export pixels as a Numpy array
原文: 11 export image
import ee
import os
import geemap
geemap.set_proxy(port=10809)
# geemap.show_youtube('_6JOA-iiEGU')
ee.Initialize()
Map = geemap.Map()
Map
Download an ee.Image
image = ee.Image('LE7_TOA_5YEAR/1999_2003')
Landsat_vis = {'bands': ['B4','B3','B2'],'gamma':1.4
}
Map.addLayer(image, Landsat_vis, "LE7_TOA_5YEAR/1999_2003", True, 0.7)
Draw an shapes on the map using the Drawing tools before executing this code block
feature = Map.draw_last_featureif feature is None:geom = ee.Geometry.Polygon([[[-115.413031, 35.889467],[-115.413031, 36.543157],[-114.034328, 36.543157],[-114.034328, 35.889467],[-115.413031, 35.889467]]])feature = ee.Feature(geom, {})roi = feature.geometry()
mage_clip = image.clip(roi).unmask()
# geemap.ee_export_image(image, filename=filename, scale=90, region=roi, file_per_band=False) #多波段单景导出
# geemap.ee_export_image(image, filename=filename, scale=90, region=roi, file_per_band=True) #单波段多景导出
# geemap.ee_export_image_to_drive(image, description='landsat', folder='export', region=roi, scale=30) #导入到google drive# geemap.ee_export_image(image_clip, filename="G:/learnpy/image/Landsat_clip.tif")
# Generating URL ...
# An error occurred while downloading.
# Pixel grid dimensions (32903x20189) must be less than or equal to 10000.
geemap.ee_export_image_to_drive(image_clip,'Landsat_clip')
Download an ee.ImageCollection
loc = ee.Geometry.Point(-99.2222, 46.7816)Collection = ee.ImageCollection('USDA/NAIP/DOQQ') \.filterBounds(loc) \.filterDate('2008-01-01', '2020-01-01') \.filter(ee.Filter.listContains("system:band_names", "N"))print(Collection.aggregate_array('system:index').getInfo())
# ['m_4609915_sw_14_060_20180902_20181213', 'm_4609915_sw_14_060_20190626', 'm_4609915_sw_14_1_20090818', 'm_4609915_sw_14_1_20100629', 'm_4609915_sw_14_1_20120714', 'm_4609915_sw_14_1_20140901', 'm_4609915_sw_14_1_20150926', 'm_4609915_sw_14_h_20160704', 'm_4609915_sw_14_h_20170703']
# Total number of images: 9geemap.ee_export_image_collection(Collection,out_dir="G:/learnpy/image")
# Exporting 1/9: m_4609915_sw_14_060_20180902_20181213.tif
# Generating URL ...
# Downloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/8d16a41edd41d1284082803398383e03-2ec0cb7bf3526f28eb5d63fa7cea6c9c:getPixels
# Please wait ...
# Data downloaded to G:\learnpy\image\m_4609915_sw_14_060_20180902_20181213.tif# Exporting 2/9: m_4609915_sw_14_060_20190626.tif
# Generating URL ...
# Downloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/7a8ad4398ad4dd29c566b8a792c9e778-1ce8d8cf577ffa2dd0a02a93d95c7e03:getPixels
# Please wait ...
# Data downloaded to G:\learnpy\image\m_4609915_sw_14_060_20190626.tif# Exporting 3/9: m_4609915_sw_14_1_20090818.tif
# Generating URL ...
# Downloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/52d24668d5fef2a5977be7cdbad95c57-059fd8ff867dc7cb644f707440408152:getPixels
# Please wait ...
# Data downloaded to G:\learnpy\image\m_4609915_sw_14_1_20090818.tif# Exporting 4/9: m_4609915_sw_14_1_20100629.tif
# Generating URL ...
# Downloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/28c559d946cf9695a99c8ef130f2ec7c-293bdf34e390abafa2b3c1a2b289c36e:getPixels
# Please wait ...
# Data downloaded to G:\learnpy\image\m_4609915_sw_14_1_20100629.tif# Exporting 5/9: m_4609915_sw_14_1_20120714.tif
# Generating URL ...
# Downloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/76696e2aa614892e4abe4173dd8a4d5e-14cd8d050c70f60388028635be8e704f:getPixels
# Please wait ...
# Data downloaded to G:\learnpy\image\m_4609915_sw_14_1_20120714.tif# Exporting 6/9: m_4609915_sw_14_1_20140901.tif
# Generating URL ...
# Downloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/4e2a4940ac033760fd03a66732930b69-03fe5f60410827d8ce5bb7a62ee4de59:getPixels
# Please wait ...
# Data downloaded to G:\learnpy\image\m_4609915_sw_14_1_20140901.tif# Exporting 7/9: m_4609915_sw_14_1_20150926.tif
# Generating URL ...
# Downloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/0357ff98bba1708f03a598f25aab1129-7714770a5f611bdc8ad41000c81dcf59:getPixels
# Please wait ...
# Data downloaded to G:\learnpy\image\m_4609915_sw_14_1_20150926.tif# Exporting 8/9: m_4609915_sw_14_h_20160704.tif
# Generating URL ...
# Downloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/a74e573f6f74cd731476f0bfecfd4142-0f693a0becda6474434c9e48df91e0b3:getPixels
# Please wait ...
# Data downloaded to G:\learnpy\image\m_4609915_sw_14_h_20160704.tif# Exporting 9/9: m_4609915_sw_14_h_20170703.tif
# Generating URL ...
# Downloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/d78940c5a6248379ec4a544ce01a1866-66c4d058f6c0378d981eb4a2dc7f3519:getPixels
# Please wait ...
# Data downloaded to G:\learnpy\image\m_4609915_sw_14_h_20170703.tif
export pixels as a Numpy array
import numpy as np
import matplotlib.pyplot as plt
img = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_038029_20180810') \.select(['B4', 'B5', 'B6'])aoi = ee.Geometry.Polygon(
[[[-110.8, 44.7],[-110.8, 44.6],[-110.6, 44.6],[-110.6, 44.7]]], None,False)rgb_img = geemap.ee_to_numpy(img, region = aoi)
rgb_img
# array([[[ 395, 1622, 1263],
# [ 399, 1711, 1263],
# [ 387, 1811, 1295],
# ...,
# [ 645, 1401, 2226],
# [ 635, 1616, 2233],
# [ 627, 1855, 2230]],# [[ 379, 1700, 1239],
# [ 426, 1745, 1341],
# [ 412, 1924, 1366],
# ...,
# [ 631, 1307, 2135],
# [ 623, 1356, 2205],
# [ 622, 1455, 2215]],# [[ 362, 1814, 1203],
# [ 507, 1814, 1397],
# [ 432, 1908, 1403],
# ...,
# [ 629, 1388, 2181],
# [ 616, 1373, 2082],
# [ 687, 1452, 2304]],# ...,# [[ 293, 1557, 1005],
# [ 314, 1560, 1001],
# [ 302, 1538, 1056],
# ...,
# [ 286, 1376, 1141],
# [ 292, 1396, 1137],
# [ 294, 1507, 1155]],# [[ 304, 1531, 997],
# [ 306, 1508, 993],
# [ 260, 1457, 884],
# ...,
# [ 276, 1169, 1030],
# [ 257, 1285, 982],
# [ 260, 1416, 1003]],# [[ 319, 1505, 1005],
# [ 302, 1527, 1040],
# [ 296, 1471, 942],
# ...,
# [ 271, 1070, 991],
# [ 272, 1152, 989],
# [ 253, 1230, 924]]])
print(rgb_img.shape)
# plt.imshow(rgb_img)
# plt.show()
# Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
rgb_img_test = (255*((rgb_img[:, :, 0:3] - 100)/3500)).astype('uint8')
plt.imshow(rgb_img_test)
plt.show()
这篇关于11_geemap学习笔记 | 导出影像的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!