付録G:オープンソースコードと算定のサンプル
Google Earth EngineデモおよびSavimbo GitHub上のISBMコードへのアクセス
最終更新
役に立ちましたか?
役に立ちましたか?
// plot18 ポリゴンを読み込む
var plot18_data = require("users/drea/map:plot18_data");
var plot18 = plot18_data.polygon;
// plot 面積をヘクタールで算出
var plotArea = plot18.area();
var plotAreaHectares = plotArea.divide(10000);
// ジャガーポイントを読み込む
var points_jaguar_data = require("users/drea/map:points_jaguar_data");
var puntos = points_jaguar_data.points;
var radios = [];
var sumMultipliedArea = ee.Number(0);
// 交差ポリゴンを格納する feature collection を定義する
var intersectionPolygons = ee.FeatureCollection([]);
// assignedArea 関数を定義する
var assignedAreaFunction = function(offset) {
var day = startDate.advance(offset, 'day');
var dayString = day.format('YYYY-MM-dd');
var feature = ee.Feature(null, { date: dayString, intersectionArea: intersectionArea });
return feature.set('date_area', ee.String(dayString).cat(' - ').cat(intersectionArea));
};
// 各ポイントのラジオとバッファを計算する
for (var i = 0; i < puntos.length; i++) {
var point = puntos[i].geometry;
var date = puntos[i].date;
// 30日を差し引いて開始日を計算する
var startDate = ee.Date(date).advance(-30, 'day');
// 30日を加算して終了日を計算する
var endDate = ee.Date(date).advance(30, 'day');
// ポイントのジオメトリと日付を属性とする feature を作成する
var feature = ee.Feature(point, { date: date });
var pointBuffer = feature.buffer(800);
radios.push(pointBuffer);
// plot18 との交差を計算する
var intersection = pointBuffer.intersection(plot18);
// 面積をヘクタールで計算する
var area = intersection.area().divide(10000);
// 日付の月と年を取得する
var month = ee.Date(date).get('month');
var year = ee.Date(date).get('year');
// 月と年のラベルを生成する
var monthYearLabel = ee.String(month).cat('-').cat(year).cat(' ヘクタール N°');
// 現在のポイントについて plot18 との交差を計算する
var intersectionPlot18 = pointBuffer.intersection(plot18);
// plot18 との交差の面積をヘクタールで計算する
var intersectionArea = intersectionPlot18.area().divide(10000);
var multipliedArea = intersectionArea.multiply(60);
// multipliedArea を合計に加算する
sumMultipliedArea = sumMultipliedArea.add(multipliedArea);
// ジャガーの期間を定義する
var jaguarRange = endDate.difference(startDate, 'day');
// ジャガーの期間の各日に intersectionArea の値を割り当てる
var assignedArea = ee.FeatureCollection(ee.List.sequence(0, jaguarRange.subtract(1)).map(assignedAreaFunction));
// 各ポイントの結果を出力する
print('ジャガー:', i + 1);
print('画像取得日:', date);
print('開始日:', startDate.format('YYYY-MM-dd'));
print('終了日:', endDate.format('YYYY-MM-dd'));
print('1日当たりの総交差面積(ヘクタール):', intersectionArea);
print('交差面積 × 60 の値:', multipliedArea);
print('1日当たりの割当面積:', assignedArea);
print('----------------------');
// 現在のポイントのバッファを青色で地図に追加する
Map.addLayer(pointBuffer, { color: 'blue' }, 'ラジオ ' + (i + 1));
// 交差ジオメトリを intersectionPolygons に追加する
intersectionPolygons = intersectionPolygons.merge(intersection);
}
// 重複を避けるためにポリゴンの union を実行する
var unionPolygons = intersectionPolygons.union();
// 重複のない交差の総面積を計算する
var totalIntersectionArea = unionPolygons.geometry().area().divide(10000);
// 結果を表示する
print('総交差面積(ヘクタール):', totalIntersectionArea);
print('plot18 の面積(ヘクタール):', plotAreaHectares);
print('交差面積の合計 × 60日(ヘクタール):', sumMultipliedArea);
// plot18 レイヤーを地図に追加する
Map.addLayer(plot18, { color: 'gold' }, "plot18");
Map.centerObject(plot18);