2017-03-12 7 views
0

화재 발생 전후의 Landsat 이미지에서 파생 된 스펙트럼 값과 밴드 값에 대해 화재 심각도 필드 측정을 관련시키는 프로젝트를 진행 중입니다. 현재 Google 어스 엔진을 사용하여 Landsat 이미지 컬렉션에서 표면 반사 값을 추출합니다. 내가 사용하고있는 접근법은 필드 사이트 위치 (포인트 데이터)를 피쳐 컬렉션으로 가져오고 getRegion 함수를 사용하여 각 포인트에서 Landsat 이미지 컬렉션에서 밴드 값을 추출합니다. 코드는 아래에 제공됩니다점으로 픽셀 값을 추출하고 Google 어스 엔진의 표로 변환

//IMPORT SAMPLE POINTS 
var pts =  ee.FeatureCollection('ft:1N9Hb01uCSHqGpz262K_f9VzWedxvTiV0g6tJwfw4'); 

//IMPORT LANDSAT IMAGE 
var L82014pre = ee.ImageCollection('LANDSAT/LC8_SR') //Landsat 8 Surface reflectance 
.filter(ee.Filter.eq('wrs_path', 94)) 
.filter(ee.Filter.eq('wrs_row', 86)) 
.filterDate(ee.Date.fromYMD(2013,12,13), ee.Date.fromYMD(2014,1,15)) 

//EXTRACT BY SAMPLE POINTS 
var sample = L82014pre.getRegion(pts, 30); 

내 질문은 내가 운전 구글에 수출 할 수있는 테이블에 결과 '샘플'변수 (리스트의리스트를) 변환 할 수있는 방법인가? 또는 Google 어스 엔진에서 포인트별로 이미지 데이터를 추출하는 더 나은 방법이 있습니까?

Google 어스 엔진 및 Java 프로그래밍 언어가 처음이므로이 질문에 대한 답변이 확실한 경우 사과드립니다. 나는이 문제에 대한 해결책을 찾기 위해 많은 시간을 보냈으며 나는 아무 것도 얻지 못하고 있다고 느낀다.

누가 복음

답변

0

나는 당신의 퓨전 테이블에 액세스 할 수 없습니다 감사합니다, 그래서 예를 들어 어떤 임의의 지점을했다. 다른 방법이있을 것이라고 확신합니다. GEE는 많은 기능을 가지고 있으며 때때로 사용하기가 다소 까다 롭습니다. 이것은 나의 방법 일 것입니다 :

// As I can't access your FusionTable, 
// I make random points and create a FeatureCollection 
var p1 = ee.Geometry.Point([142.36083984375, -37.466138602344046]) 
var p2 = ee.Geometry.Point([143.23974609375, -37.04640889969956]) 
var pts = ee.FeatureCollection(ee.List([ee.Feature(p1),ee.Feature(p2)])) 

//IMPORT LANDSAT IMAGE 
var L82014pre = ee.ImageCollection('LANDSAT/LC8_SR') //Landsat 8 Surface reflectance 
.filter(ee.Filter.eq('wrs_path', 94)) 
.filter(ee.Filter.eq('wrs_row', 86)) 
.filterDate(ee.Date.fromYMD(2013,12,13), ee.Date.fromYMD(2014,1,15)) 

// Empty Collection to fill 
var ft = ee.FeatureCollection(ee.List([])) 

var fill = function(img, ini) { 
    // type cast 
    var inift = ee.FeatureCollection(ini) 

    // gets the values for the points in the current img 
    var ft2 = img.reduceRegions(pts, ee.Reducer.first(),30) 

    // gets the date of the img 
    var date = img.date().format() 

    // writes the date in each feature 
    var ft3 = ft2.map(function(f){return f.set("date", date)}) 

    // merges the FeatureCollections 
    return inift.merge(ft3) 
} 

// Iterates over the ImageCollection 
var newft = ee.FeatureCollection(L82014pre.iterate(fill, ft)) 

// Export 
Export.table.toDrive(newft, 
"anyDescription", 
"anyFolder", 
"anyNameYouWant") 
0

@Rodrigo, 귀하의 신속한 회신에 감사드립니다. 포인트 추출 코드는 그 예제에서 완벽하게 작동했습니다. 나는 클라우드 마스크가 적용된 또 다른 이미지 집합에 대해 포인트 추출을 시도했으며 컬렉션의 첫 번째 이미지의 첫 번째 점이 마스크 (즉, 'null'값이 할당 된 픽셀) 외부에있는 경우, 내 보낸 표에는 해당 지점에 대한 대역 데이터가 포함되지 않습니다. 이 문제를 해결하기 위해 필자는 기능 컬렉션과 병합되기 전에 'null'값이 포함 된 점을 제거하는 필터를 추가했습니다.

다음은 'null'값을 제거하지 못한 실패 추출과 'null'값을 제거하는 성공적인 추출 모두를 포함하는 코드입니다.

//cloud mask ------------------------------------------------------ 
var maskCloudShadow = function(image){ 
var cfmask = image.select('cfmask'); 
return image.updateMask(cfmask.lt(1)); // keep clear (0) pixels 
}; 

//select images from image collection ----------------------------- 
//extract filtered collection of Landsat 5 Surface Reflection 
var L5fs1998post = ee.ImageCollection('LANDSAT/LT5_SR') //Landsat 5 Surface reflectance 
.filterDate('1998-1-9', '1998-2-27') //filter to date bounds 
.filter(ee.Filter.eq('wrs_path', 91))//filter to path and row 
.filter(ee.Filter.eq('wrs_row', 86)) 
.map(maskCloudShadow); //apply cloud and cloud shadow mask function 
print(L5fs1998post); 

//Create sample points -------------------------------------------- 
//var pts = 
ee.FeatureCollection('ft:1lfLgiQQSIIOpgjuZV5MZJno9_kLyQC49w6u3Hf9W'); 
var p1 = ee.Geometry.Point([146.84341192245483, -37.47371711676642]); 
var p2 = ee.Geometry.Point([146.84167385101318, -37.4]); 
var pts = ee.FeatureCollection(ee.List([ee.Feature(p1),ee.Feature(p2)])); 

// Empty Collection to fill 
var ft = ee.FeatureCollection(ee.List([])); 

//Without removal of null values ---------------------------------- 
//Function to extract values from image collection based on point file and export as a table 
var fill = function(img, ini) { 
// type cast 
var inift = ee.FeatureCollection(ini); 

// gets the values for the points in the current img 
var ft2 = img.reduceRegions(pts, ee.Reducer.first(),30); 

// gets the date of the img 
var date = img.date().format(); 

// writes the date in each feature 
var ft3 = ft2.map(function(f){return f.set("date", date)}); 

// merges the FeatureCollections 
return inift.merge(ft3); 
}; 

// Iterates over the ImageCollection 
var newft = ee.FeatureCollection(L5fs1998post.iterate(fill, ft)); 
print(newft); 

// Export 
Export.table.toDrive(newft, 
"anyDescription", 
"EarthEngine", 
"sample_include_null"); 

//With removal of null values ------------------------------------------ 
//Function to extract values from image collection based on point file and export as a table 
var fill = function(img, ini) { 
// type cast 
var inift = ee.FeatureCollection(ini); 

// gets the values for the points in the current img 
var ft2 = img.reduceRegions(pts, ee.Reducer.first(),30); 

// gets the date of the img 
var date = img.date().format(); 

// writes the date in each feature 
var ft3 = ft2.map(function(f){return f.set("date", date)}); 

// merges the FeatureCollections 

var ft3a = ft3.filter(ee.Filter.neq('B1', null));//filter first to remove null values 
return inift.merge(ft3a); 
}; 

// Iterates over the ImageCollection 
var newft_remove_null = ee.FeatureCollection(L5fs1998post.iterate(fill, ft)); 
print(newft_remove_null); 

// Export 
Export.table.toDrive(newft_remove_null, 
"anyDescription", 
"EarthEngine", 
"sample_remove_null"); 

//plot cloudy scene and sample points ------------------------------------ 
var scene = ee.Image('LANDSAT/LT5_SR/LT50910861998042'); 
Map.setCenter(147, -37.5, 9); 
Map.addLayer(scene, {bands: ['B3', 'B2', 'B1'], min: 0, max: 2000}, 'false-color composite'); 
Map.addLayer(pts);