简体   繁体   English

将GeoJSON导入具有n CRS epsg:3857坐标的传单中

[英]Importing GeoJSON into leaflet with coordinates n CRS epsg:3857

Please bear with me as I am fairly new to this whole maps things 请耐心等待,因为我对整个地图还不熟悉

I have a geojson file with the coordinates given in the epsg:3857 format 我有一个带有epsg:3857格式给定坐标的geojson文件

{"name":"2011","type":"FeatureCollection"
,"crs":{"type":"name","properties":{"name":"EPSG:3857"}}
,"features":[{  "type":"Feature",
        "geometry": {"type":"Polygon", "coordinates":[[[16455748.301877,-4074559.33797376],[16455757.520912,-4074683.80559603],[16455834.5041285,-4074749.65646613]]]},
        "properties":{"CODE":"LGA12200","LGA_NAME":"Cootamundra (A)","STATE_CODE":"1","STATE_NAME":"New South Wales","AREA_SQKM":1523.75245790713}
    }
    ]
}

When I import this into leaflet using L.geojson(....), the polygon is formed off the map... I know that this is because the coordinates are in the EPSG:3857.. 当我使用L.geojson(....)将其导入传单时,多边形是在地图上形成的……我知道这是因为坐标在EPSG:3857中。

How do I convert these to lat long coords when I import them? 导入它们时,如何将它们转换为经纬度坐标?

There are around 100 features in the geojson file geojson文件中约有100个功能

my code to import the json file is: 我导入json文件的代码是:

$.getJSON("js/output1.json", function (data) {

    // create geojson object
    L.geoJson(data).addTo(map);
}

You should convert the coordinates before you import them with L.geojson. 在使用L.geojson导入坐标之前,应先转换坐标。 Find an algorithm that does this conversion, create a parser for your geoJSON and generate a new one with the converted coordinates. 找到执行此转换的算法,为您的geoJSON创建一个解析器,并使用转换后的坐标生成一个新的解析器。 Then load them with L.geoJson. 然后用L.geoJson加载它们。

Of course you should do this on the server side, but if you only have the geoJSON file than this is the way. 当然,您应该在服务器端执行此操作,但是如果您只有geoJSON文件,则可以这样做。

Upload your geo-file in QGIS and then switch the projection to projection is EPSG:3857. 在QGIS中上传您的地理文件,然后将投影切换为EPSG:3857。 Re-save the geo-file in geoJson, 在geoJson中重新保存地理文件,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM