어스 엔진 파이썬 API가있는 기능 컬렉션의 모든 다각형에서 NDVI 평균을 얻으려고합니다. 결과 (피쳐 컬렉션에서 피쳐 컬렉션)를 얻는 데 성공했다고 생각하지만 그로부터 데이터를 가져 오는 방법을 알지 못합니다. 원하는 데이터는 각 기능의 ID 및 ndvi 평균입니다.어스 엔진 파이썬 스크립트로 결과 얻기
import datetime
import ee
ee.Initialize()
#Feature collection
fc = ee.FeatureCollection("ft:1s57dkY_Sg_E_COTe3sy1tIR_U-5Gw-BQNwHh4Xel");
fc_filtered = fc.filter(ee.Filter.equals('NUM_DECS', 1))
#Image collection
Sentinel_collection1 = (ee.ImageCollection('COPERNICUS/S2')).filterBounds(fc_filtered)
Sentinel_collection2 = Sentinel_collection1.filterDate(datetime.datetime(2017, 1, 1),datetime.datetime(2017, 8, 1))
# NDVI function to use with ee map
def NDVIcalc (image):
red = image.select('B4')
nir = image.select('B8')
ndvi = nir.subtract(red).divide(nir.add(red)).rename('NDVI')
#NDVI mean calculation with reduceRegions
MeansFeatures = ndvi.reduceRegions(reducer= ee.Reducer.mean(),collection= fc_filtered,scale= 10)
return (MeansFeatures)
#Result that I don't know to get the information: Features ID and NDVI mean
result = Sentinel_collection2.map(NDVIcalc)
대단히 감사합니다! 드라이브로 내보내는 대신 사전에 값을 가져 오는 것이 나을 것입니다. 그러나 필자는 기능 컬렉션에 수천 가지 기능이 있기 때문에 그렇게 할 것이라고 생각합니다. 내가 지금 할 수없는 유일한 일은 헤더로 내보내기입니다. javascript에서 python으로 "번역"하는 것이 조금 손실됩니다. 이것은 코드 조각입니다 (형식이 부족할 수 있습니다) : – rhal
header = ee.Feature (없음, ee.Dictionary (dates, ee.List.repeat (-1 , results = 'Tabla_stack', fileFormat = 'CSV') 작업을 인쇄합니다. (예 : date.size()))) "ok"출력 = header.merge (결과) task = ee.batch.Export.table.toDrive .start() print task.status() – rhal