如何制作 geoJson 文件并将其可视化
How to make geoJson files and visualise them
如何在 Mac 上创建 geoJson 文件?我尝试了 touch new.geojson
之后将数据复制到文件中,但我认为它没有提供正确的文件类型,因为我无法在 Kepler.gl[ 上加载文件=43=]
我尝试上传此数据,但它从未在 Kepler 上加载。如果我从互联网上尝试一些随机示例,即使格式似乎相同,它也会立即加载。
"{"type":"LineString","coordinates":[[-0.796272,5.225736],[-0.795293,5.228452],[-0.806762,5.222764],[-0.818826,5.23953],[-0.829519,5.260144],[-0.860461,5.273933],[-0.890056,5.309425],[-0.875031,5.326234],[-0.843153,5.323144],[-0.801128,5.339694],[-0.759914,5.337996],[-0.642737,5.383214],[-0.642423,5.383474],[-0.575465,5.454165],[-0.558689,5.486223],[-0.514209,5.512632],[-0.364606,5.552434],[-0.343397,5.546054],[-0.309366,5.553826],[-0.285525,5.569787],[-0.28366,5.57064],[-0.257415,5.603225],[-0.156054,5.629528],[-0.015683,5.684939],[-0.014548,5.685099],[0.054634,5.763615],[0.289173,5.86565],[0.521139,5.896969],[0.530532,6.004213],[0.555024,6.007513],[0.574476,5.990664],[0.595112,5.998843],[0.595206,5.998879],[0.664647,6.019722],[0.665004,6.019413],[0.675656,5.984694],[0.66338,5.964361],[0.690962,5.941331],[0.719717,5.890157],[0.781744,5.843708],[0.830645,5.778435],[0.919066,5.801578],[0.925173,5.788085]]}"
我认为在尝试可视化之前应该把它变成这样:
{type:"LineString",coordinates:[[-0.796272,5.225736],[-0.795293,5.228452],[-0.806762,5.222764],[-0.818826,5.23953],[-0.829519,5.260144],[-0.860461,5.273933],[-0.890056,5.309425],[-0.875031,5.326234],[-0.843153,5.323144],[-0.801128,5.339694],[-0.759914,5.337996],[-0.642737,5.383214],[-0.642423,5.383474],[-0.575465,5.454165],[-0.558689,5.486223],[-0.514209,5.512632],[-0.364606,5.552434],[-0.343397,5.546054],[-0.309366,5.553826],[-0.285525,5.569787],[-0.28366,5.57064],[-0.257415,5.603225],[-0.156054,5.629528],[-0.015683,5.684939],[-0.014548,5.685099],[0.054634,5.763615],[0.289173,5.86565],[0.521139,5.896969],[0.530532,6.004213],[0.555024,6.007513],[0.574476,5.990664],[0.595112,5.998843],[0.595206,5.998879],[0.664647,6.019722],[0.665004,6.019413],[0.675656,5.984694],[0.66338,5.964361],[0.690962,5.941331],[0.719717,5.890157],[0.781744,5.843708],[0.830645,5.778435],[0.919066,5.801578],[0.925173,5.788085]]}
但是当我尝试将它们上传到 kepler 时,它们都不起作用。我还能如何创建 geoJson 文件?
我也试过在这里复制第一种格式:
https://geoman.io/geojson-editor
之后我下载了 geoJSON 文件并尝试将其加载到 Kepler 中。即使上传 window 关闭,也没有任何反应。
编辑:
我尝试在 JsFiddle 上的 TurfJs 上执行此操作:
var stringnew = turf.lineString([-0.796272,5.225736],[-0.795293,5.228452],[-0.806762,5.222764],[-0.818826,5.23953],[-0.829519,5.260144],[-0.860461,5.273933],[-0.890056,5.309425],[-0.875031,5.326234],[-0.843153,5.323144],[-0.801128,5.339694],[-0.759914,5.337996],[-0.642737,5.383214],[-0.642423,5.383474],[-0.575465,5.454165],[-0.558689,5.486223],[-0.514209,5.512632],[-0.364606,5.552434],[-0.343397,5.546054],[-0.309366,5.553826],[-0.285525,5.569787],[-0.28366,5.57064],[-0.257415,5.603225],[-0.156054,5.629528],[-0.015683,5.684939],[-0.014548,5.685099],[0.054634,5.763615],[0.289173,5.86565],[0.521139,5.896969],[0.530532,6.004213],[0.555024,6.007513],[0.574476,5.990664],[0.595112,5.998843],[0.595206,5.998879],[0.664647,6.019722],[0.665004,6.019413],[0.675656,5.984694],[0.66338,5.964361],[0.690962,5.941331],[0.719717,5.890157],[0.781744,5.843708],[0.830645,5.778435],[0.919066,5.801578],[0.925173,5.788085])
console.log(stringnew);
console.log('hi');
但我从未在控制台上看到任何输出。我还能如何进行转换?
http://jsfiddle.net/ed8hx01c/1/
如果我 运行 这个例子,我会在控制台上看到输出:
一个有效的 geojson LineString
应该是这样的:
{
"type":"Feature",
"properties":{
},
"geometry":{
"type":"LineString",
"coordinates": [[-0.796272,5.225736],[-0.795293,5.228452],[-0.806762,5.222764],[-0.818826,5.23953],[-0.829519,5.260144],[-0.860461,5.273933],[-0.890056,5.309425],[-0.875031,5.326234],[-0.843153,5.323144],[-0.801128,5.339694],[-0.759914,5.337996],[-0.642737,5.383214],[-0.642423,5.383474],[-0.575465,5.454165],[-0.558689,5.486223],[-0.514209,5.512632],[-0.364606,5.552434],[-0.343397,5.546054],[-0.309366,5.553826],[-0.285525,5.569787],[-0.28366,5.57064],[-0.257415,5.603225],[-0.156054,5.629528],[-0.015683,5.684939],[-0.014548,5.685099],[0.054634,5.763615],[0.289173,5.86565],[0.521139,5.896969],[0.530532,6.004213],[0.555024,6.007513],[0.574476,5.990664],[0.595112,5.998843],[0.595206,5.998879],[0.664647,6.019722],[0.665004,6.019413],[0.675656,5.984694],[0.66338,5.964361],[0.690962,5.941331],[0.719717,5.890157],[0.781744,5.843708],[0.830645,5.778435],[0.919066,5.801578],[0.925173,5.788085]]
}
}
(使用 TurfJS 生成)
下载并享受可视化的乐趣!
编辑:如何使用turf.js
转到 turfjs.org 并打开开发工具控制台
粘贴以下内容:
const pseudo_line_string = {type:"LineString",coordinates:[[-0.796272,5.225736],[-0.795293,5.228452],[-0.806762,5.222764],[-0.818826,5.23953],[-0.829519,5.260144],[-0.860461,5.273933],[-0.890056,5.309425],[-0.875031,5.326234],[-0.843153,5.323144],[-0.801128,5.339694],[-0.759914,5.337996],[-0.642737,5.383214],[-0.642423,5.383474],[-0.575465,5.454165],[-0.558689,5.486223],[-0.514209,5.512632],[-0.364606,5.552434],[-0.343397,5.546054],[-0.309366,5.553826],[-0.285525,5.569787],[-0.28366,5.57064],[-0.257415,5.603225],[-0.156054,5.629528],[-0.015683,5.684939],[-0.014548,5.685099],[0.054634,5.763615],[0.289173,5.86565],[0.521139,5.896969],[0.530532,6.004213],[0.555024,6.007513],[0.574476,5.990664],[0.595112,5.998843],[0.595206,5.998879],[0.664647,6.019722],[0.665004,6.019413],[0.675656,5.984694],[0.66338,5.964361],[0.690962,5.941331],[0.719717,5.890157],[0.781744,5.843708],[0.830645,5.778435],[0.919066,5.801578],[0.925173,5.788085]]}
const line_string = turf.lineString(pseudo_line_string.coordinates);
JSON.stringify(line_string);
copy(line_string)
- 就是这样。
如何在 Mac 上创建 geoJson 文件?我尝试了 touch new.geojson
之后将数据复制到文件中,但我认为它没有提供正确的文件类型,因为我无法在 Kepler.gl[ 上加载文件=43=]
我尝试上传此数据,但它从未在 Kepler 上加载。如果我从互联网上尝试一些随机示例,即使格式似乎相同,它也会立即加载。
"{"type":"LineString","coordinates":[[-0.796272,5.225736],[-0.795293,5.228452],[-0.806762,5.222764],[-0.818826,5.23953],[-0.829519,5.260144],[-0.860461,5.273933],[-0.890056,5.309425],[-0.875031,5.326234],[-0.843153,5.323144],[-0.801128,5.339694],[-0.759914,5.337996],[-0.642737,5.383214],[-0.642423,5.383474],[-0.575465,5.454165],[-0.558689,5.486223],[-0.514209,5.512632],[-0.364606,5.552434],[-0.343397,5.546054],[-0.309366,5.553826],[-0.285525,5.569787],[-0.28366,5.57064],[-0.257415,5.603225],[-0.156054,5.629528],[-0.015683,5.684939],[-0.014548,5.685099],[0.054634,5.763615],[0.289173,5.86565],[0.521139,5.896969],[0.530532,6.004213],[0.555024,6.007513],[0.574476,5.990664],[0.595112,5.998843],[0.595206,5.998879],[0.664647,6.019722],[0.665004,6.019413],[0.675656,5.984694],[0.66338,5.964361],[0.690962,5.941331],[0.719717,5.890157],[0.781744,5.843708],[0.830645,5.778435],[0.919066,5.801578],[0.925173,5.788085]]}"
我认为在尝试可视化之前应该把它变成这样:
{type:"LineString",coordinates:[[-0.796272,5.225736],[-0.795293,5.228452],[-0.806762,5.222764],[-0.818826,5.23953],[-0.829519,5.260144],[-0.860461,5.273933],[-0.890056,5.309425],[-0.875031,5.326234],[-0.843153,5.323144],[-0.801128,5.339694],[-0.759914,5.337996],[-0.642737,5.383214],[-0.642423,5.383474],[-0.575465,5.454165],[-0.558689,5.486223],[-0.514209,5.512632],[-0.364606,5.552434],[-0.343397,5.546054],[-0.309366,5.553826],[-0.285525,5.569787],[-0.28366,5.57064],[-0.257415,5.603225],[-0.156054,5.629528],[-0.015683,5.684939],[-0.014548,5.685099],[0.054634,5.763615],[0.289173,5.86565],[0.521139,5.896969],[0.530532,6.004213],[0.555024,6.007513],[0.574476,5.990664],[0.595112,5.998843],[0.595206,5.998879],[0.664647,6.019722],[0.665004,6.019413],[0.675656,5.984694],[0.66338,5.964361],[0.690962,5.941331],[0.719717,5.890157],[0.781744,5.843708],[0.830645,5.778435],[0.919066,5.801578],[0.925173,5.788085]]}
但是当我尝试将它们上传到 kepler 时,它们都不起作用。我还能如何创建 geoJson 文件?
我也试过在这里复制第一种格式: https://geoman.io/geojson-editor
之后我下载了 geoJSON 文件并尝试将其加载到 Kepler 中。即使上传 window 关闭,也没有任何反应。
编辑:
我尝试在 JsFiddle 上的 TurfJs 上执行此操作:
var stringnew = turf.lineString([-0.796272,5.225736],[-0.795293,5.228452],[-0.806762,5.222764],[-0.818826,5.23953],[-0.829519,5.260144],[-0.860461,5.273933],[-0.890056,5.309425],[-0.875031,5.326234],[-0.843153,5.323144],[-0.801128,5.339694],[-0.759914,5.337996],[-0.642737,5.383214],[-0.642423,5.383474],[-0.575465,5.454165],[-0.558689,5.486223],[-0.514209,5.512632],[-0.364606,5.552434],[-0.343397,5.546054],[-0.309366,5.553826],[-0.285525,5.569787],[-0.28366,5.57064],[-0.257415,5.603225],[-0.156054,5.629528],[-0.015683,5.684939],[-0.014548,5.685099],[0.054634,5.763615],[0.289173,5.86565],[0.521139,5.896969],[0.530532,6.004213],[0.555024,6.007513],[0.574476,5.990664],[0.595112,5.998843],[0.595206,5.998879],[0.664647,6.019722],[0.665004,6.019413],[0.675656,5.984694],[0.66338,5.964361],[0.690962,5.941331],[0.719717,5.890157],[0.781744,5.843708],[0.830645,5.778435],[0.919066,5.801578],[0.925173,5.788085])
console.log(stringnew);
console.log('hi');
但我从未在控制台上看到任何输出。我还能如何进行转换?
http://jsfiddle.net/ed8hx01c/1/
如果我 运行 这个例子,我会在控制台上看到输出:
一个有效的 geojson LineString
应该是这样的:
{
"type":"Feature",
"properties":{
},
"geometry":{
"type":"LineString",
"coordinates": [[-0.796272,5.225736],[-0.795293,5.228452],[-0.806762,5.222764],[-0.818826,5.23953],[-0.829519,5.260144],[-0.860461,5.273933],[-0.890056,5.309425],[-0.875031,5.326234],[-0.843153,5.323144],[-0.801128,5.339694],[-0.759914,5.337996],[-0.642737,5.383214],[-0.642423,5.383474],[-0.575465,5.454165],[-0.558689,5.486223],[-0.514209,5.512632],[-0.364606,5.552434],[-0.343397,5.546054],[-0.309366,5.553826],[-0.285525,5.569787],[-0.28366,5.57064],[-0.257415,5.603225],[-0.156054,5.629528],[-0.015683,5.684939],[-0.014548,5.685099],[0.054634,5.763615],[0.289173,5.86565],[0.521139,5.896969],[0.530532,6.004213],[0.555024,6.007513],[0.574476,5.990664],[0.595112,5.998843],[0.595206,5.998879],[0.664647,6.019722],[0.665004,6.019413],[0.675656,5.984694],[0.66338,5.964361],[0.690962,5.941331],[0.719717,5.890157],[0.781744,5.843708],[0.830645,5.778435],[0.919066,5.801578],[0.925173,5.788085]]
}
}
(使用 TurfJS 生成)
下载并享受可视化的乐趣!
编辑:如何使用turf.js
转到 turfjs.org 并打开开发工具控制台
粘贴以下内容:
const pseudo_line_string = {type:"LineString",coordinates:[[-0.796272,5.225736],[-0.795293,5.228452],[-0.806762,5.222764],[-0.818826,5.23953],[-0.829519,5.260144],[-0.860461,5.273933],[-0.890056,5.309425],[-0.875031,5.326234],[-0.843153,5.323144],[-0.801128,5.339694],[-0.759914,5.337996],[-0.642737,5.383214],[-0.642423,5.383474],[-0.575465,5.454165],[-0.558689,5.486223],[-0.514209,5.512632],[-0.364606,5.552434],[-0.343397,5.546054],[-0.309366,5.553826],[-0.285525,5.569787],[-0.28366,5.57064],[-0.257415,5.603225],[-0.156054,5.629528],[-0.015683,5.684939],[-0.014548,5.685099],[0.054634,5.763615],[0.289173,5.86565],[0.521139,5.896969],[0.530532,6.004213],[0.555024,6.007513],[0.574476,5.990664],[0.595112,5.998843],[0.595206,5.998879],[0.664647,6.019722],[0.665004,6.019413],[0.675656,5.984694],[0.66338,5.964361],[0.690962,5.941331],[0.719717,5.890157],[0.781744,5.843708],[0.830645,5.778435],[0.919066,5.801578],[0.925173,5.788085]]}
const line_string = turf.lineString(pseudo_line_string.coordinates);
JSON.stringify(line_string);
copy(line_string)
- 就是这样。