- 大家好,
- 我正在使用 OpenLayers 5、Angular 6、mapshaper 工具(将 shp 转换为 json)。
- MapshaperTool , Git 代码
我的过程
- 我已经安装了npm mapshaper --save
我能够上传不同的 .shp 文件并能够获取 json 特征数据。
我有 2 个不同的 .shp 文件 [layer-ind.shp, layer-administration.shp]
- layer-ind.shp 文件上传了它的 json 给喜欢
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
75.89355468749999,
18.521283325496277
],
[
80.6396484375,
19.68397023588844
]
]
}
}
]
}
- layer-us.shp 文件上传了它的 json 给喜欢
{
"type": "FeatureCollection",
"features": [
{
"type":"Feature",
"geometry":{
"type":"LineString",
"coordinates":[
[-349771.1875,445307.8125],
[-349789.6875,445314.375],
[-349796.5625,445321.5625],
[-349792.78119999915,445341.4375],
[-349786.53119999915,445351.71880000085],
[-349771.1875,445307.8125]]},
"properties":{
"TYPE":"ISLAND","RuleID":3,
"Shape_Leng":544.475438955
}
}
]
}
当在地图上预览这两个图层(功能)时 1. layer-ind.json 文件给出了正确的结果,并且能够在正确的位置看到地图上的图层 2. layer-us.json 文件给出了在地图上显示的错误位置 (0,0)
- 如何解决这些第二点 layer-us.json 问题,我也改变了重新投影
const vectorSource = new VectorSource({
features: (new GeoJSON()).readFeatures(geojson, {
featureProjection: 'EPSG:4326'
});
});
- 我也更改了 featureProjection 代码,但它不工作 layer-us.json。
请帮忙
拯救我的日子