Public
Edited
Jun 4, 2023
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bhutan_directory = fetch('https://corsproxy.io/?' + encodeURIComponent(bhutan_directory_url)).then(response => response.json())
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
arcgisRestFeatureLayer = require('@esri/arcgis-rest-feature-layer@3.4.2/dist/umd/feature-layer.umd.js')
Insert cell
Insert cell
bhutan_baselayers_outline = arcgisRestFeatureLayer.queryFeatures({
url: 'https://corsproxy.io/?' + encodeURIComponent('http://geoapps.icimod.org/icimodarcgis/rest/services/Bhutan/Basemap/MapServer/0'),
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
arcgis_to_geojson = require('@terraformer/arcgis@2.1.2')
Insert cell
Insert cell
bhutan_baselayers_outline_geojson = arcgis_to_geojson.arcgisToGeoJSON(bhutan_baselayers_outline)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function fetchAllResults(url, resultOffset) {
return new Promise((resolve, reject) => {
const resultsPerPage = 1000;
const allResults = [];

function fetchPage(offset) {
arcgisRestFeatureLayer.queryFeatures({
url: url,
resultOffset: offset,
resultRecordCount: resultsPerPage
}).then(response => {
const features = response.features;
allResults.push(...features);

if (features.length === resultsPerPage) {
fetchPage(offset + resultsPerPage); // Fetch the next page
} else {
resolve(allResults); // Resolve the promise with all results
}
}).catch(reject);
}

fetchPage(resultOffset);
});
}
Insert cell
Insert cell
bhutan_roads_all_attributes = fetchAllResults("https://corsproxy.io/?http%3A%2F%2Fgeoapps.icimod.org%2Ficimodarcgis%2Frest%2Fservices%2FBhutan%2FBasemap%2FMapServer%2F4", 0)
Insert cell
Insert cell
function swapFeatures(limited_request, full_results) {
if (limited_request.hasOwnProperty('features') && Array.isArray(full_results)) {
limited_request.features = full_results;
}
return limited_request
}
Insert cell
Insert cell
bhutan_roads_all_attributes_remapped = swapFeatures(bhutan_baselayers_road, bhutan_roads_all_attributes)
Insert cell
Insert cell
bhutan_baselayers_road_geojson_all_attributes = arcgis_to_geojson.arcgisToGeoJSON(bhutan_roads_all_attributes_remapped)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
image_data = fetch('https://geoapps.icimod.org/icimodarcgis/rest/services/Bhutan/Landcover/MapServer' + "?f=pjson"
).then((response) => response.json())
Insert cell
Insert cell
url_export = "https://geoapps.icimod.org/icimodarcgis/rest/services/Bhutan/Landcover/MapServer/export?"
+ "dpi=96" +
"&transparent=true" +
"&format=" +
select_format +
"&layers=show%3A" +
select_layers +
"&bbox=" +
image_data.fullExtent.xmin +
"," +
image_data.fullExtent.ymin +
"," +
image_data.fullExtent.xmax +
"," +
image_data.fullExtent.ymax +
"bboxSR=" +
image_data.spatialReference.wkid +
"," +
"imageSR=" +
image_data.spatialReference.wkid +
"size=" +
image_data.maxImageWidth +
"," +
image_data.maxImageHeight +
"&f=image"
Insert cell
Insert cell
url_spec = 'https://geoapps.icimod.org/icimodarcgis/rest/services/Bhutan/Landcover/MapServer' + "/export?bbox=" + image_data.fullExtent.xmin + "," + image_data.fullExtent.ymin + "," + image_data.fullExtent.xmax + "," + image_data.fullExtent.ymax + "bboxSR=" + image_data.spatialReference.wkid + "," + "imageSR=" + image_data.spatialReference.wkid +"&layers=show:" + select_layers + "size=" + image_data.maxImageWidth + "," + image_data.maxImageHeight +"&format=" + select_format + "&transparent=true" + "&dpi=" + "&f=pjson"
Insert cell
result = fetch(url_spec).then((response) => response.json())
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
world_file=`
${(image_data.fullExtent.xmax - image_data.fullExtent.xmin)/(width - 1)}
0
0
-${(image_data.fullExtent.ymax - image_data.fullExtent.ymin)/(width - 1)}
${image_data.fullExtent.xmin}
${image_data.fullExtent.ymax}
`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more