使用python在Google Earth引擎中查询大型FeatureCollection
我正在尝试处理从下载的坦桑尼亚形状文件 将使用python在Google Earth引擎中查询大型FeatureCollection,python,shapefile,google-earth-engine,Python,Shapefile,Google Earth Engine,我正在尝试处理从下载的坦桑尼亚形状文件 将self.scale更改为10会引发以下行错误: featureCollection.getInfo() ee.ee_exception.EEException:服务器返回的HTTP代码:413 将self.scale更改为1000会引发此错误: ee.ee_exception.EEException:计算超时 处理具有较大区域的形状文件的正确方法是什么?请注意,对地球引擎API的请求是。因此,您的代码对解决问题没有多大作用。这些错误是如何从您发布的代
self.scale
更改为10会引发以下行错误:
featureCollection.getInfo()
ee.ee_exception.EEException:服务器返回的HTTP代码:413
将self.scale
更改为1000会引发此错误:
ee.ee_exception.EEException:计算超时
处理具有较大区域的形状文件的正确方法是什么?请注意,对地球引擎API的请求是。因此,您的代码对解决问题没有多大作用。这些错误是如何从您发布的代码中产生的并不明显,但在任何一种情况下,答案都可能是相同的:导出结果。例如:
import ee
ee.Initialize()
image = ee.Image('srtm90_v4')
geometry = ee.Geometry.Polygon([[[-113.64, 39.97], [-113.64, 38.13],[-109.42, 38.13],[-109.42, 39.97]]], None, False)
dict = image.reduceRegion(reducer=ee.Reducer.mean(), geometry=geometry, scale=1000)
featureCollection = ee.FeatureCollection([ee.Feature(None, dict)])
task = ee.batch.Export.table.toDrive(collection=featureCollection, description='foo', fileNamePrefix='foo', fileFormat='CSV')
task.start()
print task.status()
导出的输出将在您的Google Drive文件夹中具体化。要了解有关scale的更多信息,请参阅。鉴于此问题是关于地理空间处理的,它似乎更适合于特定领域的gis.stackexchange.com,而不是一般的stackoverflow.com。
def getInfo_werrorcontrol(featureCollection, errorcontrolon=True):
"""
Wrapper to add error control to GEE evaluations.
For large computations GEE sometimes times out and needs to be
restarted. This does so in a controlled manner with out
interrrupting the program flow.
"""
if errorcontrolon:
i=0
while True:
try:
with timeout.timeout(10*60):
return featureCollection.getInfo() # In this line I am getting exception.
except NameError:
exc_type, exc_value, exc_traceback = sys.exc_info()
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
print ''.join('!! ' + line for line in lines)
i+=1
print 'attempts: '+str(i)
if i > 20:
raise ValueError('to many attempts')
elif i > 10:
print 'waiting 2 minutes'
time.sleep(60*2)
else:
return featureCollection.getInfo()
import ee
ee.Initialize()
image = ee.Image('srtm90_v4')
geometry = ee.Geometry.Polygon([[[-113.64, 39.97], [-113.64, 38.13],[-109.42, 38.13],[-109.42, 39.97]]], None, False)
dict = image.reduceRegion(reducer=ee.Reducer.mean(), geometry=geometry, scale=1000)
featureCollection = ee.FeatureCollection([ee.Feature(None, dict)])
task = ee.batch.Export.table.toDrive(collection=featureCollection, description='foo', fileNamePrefix='foo', fileFormat='CSV')
task.start()
print task.status()