【问题标题】:geoJSON formatting needs to be nested more deeplygeoJSON 格式需要嵌套更深
【发布时间】:2020-09-17 17:03:35
【问题描述】:

我有一个导出的geoJSON 格式,其中包含一长串多边形坐标。附加前几行,以同样的方式继续:

{
  "Type": 8,
  "Features": [
    {
      "Type": 7,
      "Id": null,
      "Geometry": {
        "Type": 4,
        "Coordinates": [
          {
            "Type": 2,
            "Coordinates": [
              {
                "Altitude": null,
                "Latitude": 85.683948266763423,
                "Longitude": 100.62897140939768
              },
              {
                "Altitude": null,
                "Latitude": 86.183185093020128,
                "Longitude": 100.62897140939695
              },
              {
                "Altitude": null,
                "Latitude": 86.183185093020128,
                "Longitude": 102.58500571589823
              },
              {
                "Altitude": null,
                "Latitude": 97.662303996119974,
                "Longitude": 102.58500571589828
              },
              {
                "Altitude": null,
                "Latitude": 97.662303996119988,
                "Longitude": 97.853903401585853
              },
              {
                "Altitude": null,
                "Latitude": 85.683948266763423,
                "Longitude": 97.853903401585839
              },
              {
                "Altitude": null,
                "Latitude": 85.683948266763423,
                "Longitude": 100.62897140939768
              }
            ],
            "BoundingBoxes": null,
            "CRS": null
          }
        ],
        "BoundingBoxes": null,
        "CRS": null
      },
      "Properties": {
        "Name": "Shop",
        "Area": 572.15969696515185
      },
      "BoundingBoxes": null,
      "CRS": null
    },
    {
      "Type": 7,
      "Id": null,
      "Geometry": {
        "Type": 4,
        "Coordinates": [
          {
            "Type": 2,
            "Coordinates": [
              {
                "Altitude": null,
                "Latitude": 91.298364266763443,
                "Longitude": 86.631773715898134
              },
              {

我尝试在网上查看geoJSON 格式的各种解释,但没有找到关于为什么"Type" 是数字并且与"Polygon" 等实际类型不匹配的信息。

另外,在GeoJSON Viewer & Validator 上进行测试时,我尝试调试并将一些初始行转换为:

{
  "type": "MultiPolygon",
  "coordinates": [
    {
      "type": 7,
      "Id": null,
      "Geometry": {
        "Type": "Polygon",
        "Coordinates": [
          {
            "Type": 2,
            "Coordinates": [
              {
                "Altitude": null,
                "Latitude": 85.683948266763423,
                "Longitude": 100.62897140939768
              },

我将Type 替换为type,将8 替换为MultiPolygon 等。 在上述情况下,每个多边形都会出现以下错误:

第 5 行:在坐标数组应该存在的位置找到了一个数字 发现:这需要嵌套更深

我不确定要对格式进行哪些更改以使其与验证器保持一致。我认为导出格式可能很旧,但我不是构建它的人,所以也许手动替换某些字段可以解决问题。

有什么建议吗?

【问题讨论】:

    标签: json formatting polygon geojson


    【解决方案1】:

    聚会有点晚了,但它似乎不是有效的 GeoJSON,您可以在此处找到描述规范的官方 JSON 模式: https://github.com/geojson/schema。 例如指定一个特征的type应该是一个JSON对象而不是一个整数,对于每个特征,typepropertiesgeometry都是必需的,等等。

      "$schema": "http://json-schema.org/draft-07/schema#",
      "$id": "https://geojson.org/schema/Feature.json",
      "title": "GeoJSON Feature",
      "type": "object",
      "required": [
        "type",
        "properties",
        "geometry"
      ]
    (etc.)
    

    对于 MultiPolygon,这里是架构:https://geojson.org/schema/MultiPolygon.json

    坐标在文件中的存储方式也不是标准的 GeoJSON,因为它们应该写成数字数组:

    "coordinates": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": "array",
              "minItems": 4,
              "items": {
                "type": "array",
                "minItems": 2,
                "items": {
                  "type": "number"
                }
              }
            }
          }
        }
    

    【讨论】:

      猜你喜欢
      • 2018-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-15
      • 1970-01-01
      • 1970-01-01
      • 2015-05-05
      • 1970-01-01
      相关资源
      最近更新 更多