분류 할 16 진수 그리드가 있습니다. 터프, 전단지로 헥스 격자를 분류하십시오.
는 제가 로 값을 집계var hexgrid = turf.hexGrid(bbox, cellWidth, units);
와 육각 생성
var aggregated = turf.collect(hexgrid, myGeoJson, 'MyValue', 'NewCol');
myGeoJson 멀티 포인트 FeatureCollection이고 MyValue 널 또는> 0
어느 기능 속성이고 난 16 진수를 필터링
var hexFiltered = L.geoJson(aggregated, {
filter: function(feature, layer) {
return feature.properties.NewCol.length > 0;
}
}).addTo(map);
,
각 육각 객체
console.log(hexFiltered["_layers"]);
output = Object { 49: Object, 51: Object, 52: Object, 53: Object...
으로 액세스 할 수있는 각 오브젝트 후 갖는다 .feature.properties.NewCol [N] 각 배열 인덱스 (0, 1, 2) 및 값 (NULL 1 갖는다 +)
각 16 진수 그리드를 배열 값의 합계로 어떻게 분류 할 수 있습니까?
나는 이것을 네이티브 자바 스크립트로 시도했지만, 나는 모든 값을 가진 문자열이다.
var counts = {};
for (var obj in hexFiltered["_layers"]) {
// Output the id of each obj (hex)
// console.log("Object: " + obj);
var cnt = 0;
for (var i in hexFiltered["_layers"][obj]["feature"]["properties"]) {
// print values out as 1 line (i)
console.log("One line of values :" + hexFiltered["_layers"][obj]["feature"]["properties"][i]);
// output = One line of values :,,,1,,,,1,1,,1
// add values
cnt = cnt + hexFiltered["_layers"][obj]["feature"]["properties"][i];
console.log(cnt);
// output = 0,,,1,,,,1,1,,1
}
// attach cnt to counts object
counts += cnt;
}
어디로 가고 있습니까? 더 쉬운 방법이 있습니까?