Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.
Hsu Ting edited this page Nov 26, 2015 · 8 revisions

Convert to geojson

convert2geojson is used to convert files into geojson format, and can open a simple map to show all data.

Command

  • -ncv -> (does) not convert data to geojson
  • -test -> open simple map

Simple map

Simple Map

json

  • Every format is acceptable, but data must have a min unit.
  • Identical field names will be collected in an array.
  • Data examples:
  1. Point
    • It can be a number or an array, such as 20 or [10, 20, 30].
    • If using an array, the number of Longitude values must be equal to the number of Latitude values.
  2. LineString
    • It can be an array, such as [ [10, 20], [20, 30] ].
  3. Polygon
    • It can be an array, such as [ [[10, 20], [20, 30]], [[24, 53], [23, 54]] ].
  • Example:

Input

[
  {
    "name": "title",
    "data": {
      "Lon": "120",
      "Lat": "24",
      "num": "test",
      "test": {
        "num": "0",
        "try": "1",
        "array": [
          {"num": "24"}
        ]   
      }   
    }   
  },  
  {
    "name": "title2",
    "data": {
      "Lon": "120.2",
      "Lat": "24.1",
      "num": "test",
      "test": {
        "num": "2",
        "try": "5",
        "array": [
          {"num": "10"},
          {"num": "2"}
        ]   
      }   
    }   
  }
]

Output

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          120,
          24
        ]
      },
      "properties": {
        "name": "title",
        "num": [
          "test",
          "0",
          "24"
        ],
        "try": "1",
        "lon": "120",
        "lat": "24"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          120.2,
          24.1
        ]
      },
      "properties": {
        "name": "title2",
        "num": [
          "test",
          "2",
          "10",
          "2"
        ],
        "try": "5",
        "lon": "120.2",
        "lat": "24.1"
      }
    }
  ]
}

csv

  • csv convert to Point only.

Input

Date,Lat,Lon,Value
10/15,21,20,100
10/25,12,34,50
10/25,14,52,83

Output

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          20,
          21
        ]
      },
      "properties": {
        "Date": "10/15",
        "Lat": "21",
        "Lon": "20",
        "Value": "100"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          34,
          12
        ]
      },
      "properties": {
        "Date": "10/25",
        "Lat": "12",
        "Lon": "34",
        "Value": "50"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          52,
          14
        ]
      },
      "properties": {
        "Date": "10/25",
        "Lat": "14",
        "Lon": "52",
        "Value": "83"
      }
    }
  ]
}
Clone this wiki locally