วิเคราะห์ข้อมูลของคุณ
ทำ buffer, aggregate, หาจุดที่ใกล้ที่สุด และ intersect กับ GeoJSON ผ่าน endpoint วิเคราะห์ของ MapScale แล้วแสดงผลลัพธ์บนแผนที่
ปานกลาง
ฟังก์ชันที่ใช้ได้
การวิเคราะห์ 4 แบบรับ GeoJSON และคืน GeoJSON ต้องใช้ secret key จึงต้องเรียกจากเซิร์ฟเวอร์ของคุณ ฟิลด์ที่แต่ละฟังก์ชันรับดูได้ใน API reference ตัวอย่างในหน้านี้แสดงรูปแบบการเรียก ไม่ใช่ชื่อฟิลด์ที่ตายตัว
POST /v1/analysis/buffer area within a distance of each feature
POST /v1/analysis/aggregate count or summarize features per province, district, subdistrict or hex cell
POST /v1/analysis/nearest the closest features to a point
POST /v1/analysis/intersect which features of one dataset overlap features of anotherเรียกใช้การวิเคราะห์
ส่งข้อมูล feature และตัวเลือกของฟังก์ชันเป็น JSON body
# Buffer every feature of one of your datasets by 1 km (meters: 0.1 to 50000).
curl -X POST "https://api.mapscale.io/v1/analysis/buffer" \
-H "x-api-key: sk_live_YOUR_SECRET_KEY" \
-H "content-type: application/json" \
-d '{ "datasetId": "YOUR_DATASET_ID", "meters": 1000 }'
# The response is a GeoJSON FeatureCollection you can draw on the map.
# Other operations take the same datasetId:
# aggregate { "datasetId": "...", "groupBy": "province", "property": "staff" }
# aggregate { "datasetId": "...", "groupBy": "hex", "cellMeters": 5000 }
# nearest { "datasetId": "...", "lon": 100.54, "lat": 13.74, "k": 3 }
# intersect { "datasetIdA": "...", "datasetIdB": "..." }แสดงผลลัพธ์
ผลลัพธ์เป็น GeoJSON ธรรมดา เพิ่มเข้าแผนที่ MapLibre เป็น geojson source ได้เลย หรืออัปโหลดเป็น dataset ใหม่เพื่อให้บริการเป็น tile
// result = the GeoJSON FeatureCollection the analysis call returned
map.addSource("result", { type: "geojson", data: result })
map.addLayer({
id: "result-fill",
type: "fill",
source: "result",
paint: { "fill-color": "#b45309", "fill-opacity": 0.3 },
})ใช้ร่วมกับแคตตาล็อกข้อมูล
แคตตาล็อกข้อมูลรวมเลเยอร์ของประเทศไทยที่ MapScale เผยแพร่ เช่น เลเยอร์ภัยพิบัติและข้อมูลอ้างอิง อ่านรายละเอียดของเลเยอร์เพื่อดูวิธีใช้ แล้วนำไปวิเคราะห์ร่วมกับข้อมูลของคุณ
# Thailand data catalog: list layers, then read one layer's details.
curl "https://api.mapscale.io/v1/catalog" -H "x-api-key: sk_live_YOUR_SECRET_KEY"
curl "https://api.mapscale.io/v1/catalog/LAYER_ID" -H "x-api-key: sk_live_YOUR_SECRET_KEY"