9

I was testing rendering of data via GitHub in geojson format, because I wanted to use it for INSPIRE data. INSPIRE data are in GML 3.2.1 format. I've downloaded one of datasets from http://services.cuzk.cz/gml/inspire/cp/epsg-4258/ (which is in ETRS). I needed to get json file from it, so I've opened GML file in Quantum GIS (version 1.9) and saved it like geojson file (CRS=EPSG::4326) and then uploaded to my GitHub. Order of coordinates in geojson is (easting, northing), but after saving file from QGIS it's (northing, easting). My data comes from Czech Republic, but it's rendered in Yemen. Does anybody have any experience with this problem? Does anybody know how to switch order of coordinates (or axis) in geojson file? I have much more experience with xml based data formats than with json and because of that I hope that this isn't so silly question.

4

2 回答 2

31

对于在那里寻找标题中问题答案的任何人:

坐标顺序是经度和纬度,或东和北。

资源:

3.1.1。位置

位置是基本的几何结构。Geometry 对象的“坐标”成员由以下任一项组成:

o 在点几何体的情况下一个位置,

o 在 LineString 或 MultiPoint 几何体的情况下的位置数组,

o 在 Polygon 或 MultiLineString 几何体的情况下,LineString 或线性环(参见第 3.1.6 节)坐标数组,或

o 在 MultiPolygon 几何体的情况下,Polygon 坐标数组。

位置是一个数字数组。必须有两个或更多
元素。 前两个元素是 longitude 和 latitude,或者
easting 和 northing
,完全按照这个顺序并使用十进制
数字。高度或海拔可以作为可选的第三个
元素包括在内。

来自GeoJSON 规范

于 2019-08-26T07:53:48.117 回答
0

可以使用python切换坐标顺序:

import json
import sys

geodata = json.loads(open(sys.argv[1]).read())
for obj in geodata:
    if "coordinates" in obj:
        # reorder from northing, easting to easting, northing
        northing = obj["coordinates"][0]
        easting = obj["coordinates"][1]
        obj["coordinates"] = [ easting, northing ]

print json.dumps(geodata)

像这样运行它:

python reorder_geojson.py geodata_ne.json > geodata_en.json
于 2013-10-07T03:53:41.950 回答