# 부록 G: 오픈소스 코드 및 계산 샘플

생물다양성 크레딧 산정용 오픈소스 코드는 다음에서 일반에 공개되어 있습니다. [Savimbo GitHub](https://github.com/savimbo).&#x20;

당사는 2024년 생물다양성 인증을 시작한 이후, 무료 Airtable 데이터베이스와 연동하여 자동으로 크레딧을 부여하고 받을 수 있는 인터페이스를 통해 이 코드를 보다 쉽게 사용할 수 있도록 하고, 원주민(IP) 및 지역 공동체(LC) 프로젝트에도 제공할 의도를 가지고 있습니다. 무료 Airtable [가입 ](https://airtable.com/invite/r/fxsn6mcE)은 현재 이용 가능합니다. IP 프로젝트는 지금 이 인터페이스의 대기자 명단에 가입할 수 있으며, <ops@savimbo.com>으로 이메일을 보내 Airtable 데이터베이스 템플릿을 받을 수 있습니다.

데모 산정도 이용 가능합니다. Google Earth Engine은 기후변화에 관여하는 원주민 단체에 무료 계정을 제공하겠다고 약속하였습니다. 비상업용 [가입](https://earthengine.google.com/noncommercial/) 이 이용 가능합니다.&#x20;

**그림 11. Google Earth Engine 코드 샘플**&#x20;

<figure><img src="https://lh6.googleusercontent.com/rVQ0Wv_v9_eXa7qOghqAvJhwResowct17qRiUSD-lO_eatzZqyiNhfpKmprKNcRWdVXXkv2FuYyAetkdA1BzOcf6d7EWeGqmRpKVVMGmk89gLOQd8i1K-Ia4A7ixXu0Xo2XSlovBPF8KPN24COHu6a4" alt=""><figcaption><p><em><strong>그림 11</strong></em>. Google Earth Engine 코드 샘플</p></figcaption></figure>

코드 샘플, 외부 검토 중인 코드입니다. 이 [링크를 통해 Google Earth Engine에서 접근할 수 있습니다.](https://code.earthengine.google.com/e914e4bf1b4fd252f4ad90318ca2371e) 또는 다음의 Savimbo GitHub에서 [링크를 통해 Google Earth Engine에서 접근할 수 있습니다.](https://github.com/savimbo) 문의 ***ops at savimbo.co**m* 코드 검토자가 되고 싶으시다면 연락해 주십시오.&#x20;

```markup
// plot18 폴리곤 로드
var plot18_data = require("users/drea/map:plot18_data");
var plot18 = plot18_data.polygon;

// 플롯 면적을 헥타르 단위로 계산
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);

// 교차 폴리곤을 저장할 피처 컬렉션 정의
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');
  
  // 포인트 기하와 날짜를 속성으로 하는 피처 생성
  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('일별 총 교차 면적(헥타르):', intersectionArea);
  print('교차 면적 × 60:', multipliedArea);
  print('일별 할당 면적:', assignedArea);
  print('----------------------');
  
  // 현재 포인트 버퍼를 파란색으로 지도에 추가
  Map.addLayer(pointBuffer, { color: 'blue' }, '반경 ' + (i + 1));
  
  // 교차 기하를 intersectionPolygons에 추가
  intersectionPolygons = intersectionPolygons.merge(intersection);
}

// 중복 방지를 위한 폴리곤 합집합 수행
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);

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://isbm.savimbo.com/methodology/savimbo-indicator-species-biodiversity-method-ko/appendices/g.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
