GeoJSON is a geospatial data interchange format based on JavaScript Object Notation (JSON). It defines several types of JSON objects and the manner in which they are combined to represent data about geographic features, their properties, and their spatial extents. GeoJSON uses a geographic coordinate reference system, World Geodetic System 1984, and units of decimal degrees.
Table of Contents
A GeoJSON Feature Collection looks like this:
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [102.0, 0.5]
},
"properties": {
"prop0": "value0"
}
}, {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 0.0],
[103.0, 1.0],
[104.0, 0.0],
[105.0, 1.0]
]
},
"properties": {
"prop0": "value0",
"prop1": 0.0
}
}, {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0]
]
]
},
"properties": {
"prop0": "value0",
"prop1": {
"this": "that"
}
}
}]
}
A GeoJSON object have 3 types:
The GeoJSON object Geometry includes 7 types:
Notes:
A Geometry (except GeometryCollection) consists of two parts: type
and coordinates
.
{
"type": "Point",
"coordinates": [102.0, 0.5]
}
The value of type
property can be choosen from the 7 geometry types we talked above.
The format of the value of coordinates
property differs.
Here are some definitions help to understand the following table:
[longitude/easting, latitude/northing, ?altitude/elevation]
Geometryg | coordinates Format | Example |
---|---|---|
Point | a single position | [103.0 31.0] |
MultiPoint | an array of positions | [ [103.0, 31.0] ] |
LineString | an array of two or more positions | [ [103.0, 31.0], [104.0, 31.0] ] |
MultiLineString | an array of LineString coordinate arrays | [ [[103.0, 31.0], [104.0, 31.0]] ] |
Polygon | an array of linear ring coordinate arrays (the first must be the exterior ring: [exterior, ...interiors] ) |
[ [[102.0, 31.0], [103.0, 31.0], [104.0, 31.0]] ] |
MultiPolygon | an array of Polygon coordinates | [ [[[102.0, 31.0], [103.0, 31.0], [104.0, 31.0]]]] ] |
Compared with the other geometries, GeometryCollection do not have the coordiantes
member and have a new member called geometries
instead. It looks like this:
{
"type": "GeometryCollection",
"geometries": [
{
"type": "Point",
"coordinates": [102.0, 0.5]
},
{
"type": "LineString",
"coordinates": [
[102.0, 0.0],
[103.0, 1.0],
[104.0, 0.0],
[105.0, 1.0]
]
}
]
}
There are some suggestions for GeometryCollection:
Any geometry that crosses the antimeridian SHOULD be represented by cutting it in two such that neither part’s representation crosses the antimeridian. For example, if a Polygon across the antimeridian, it should be cutted in two and represented as a MultiPolygon.
A Feature object represents a spatially bounded thing. It has three members: type
, geometry
(do not confused with geometries
in GeometryCollection) and properties
:
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 0.0],
[103.0, 1.0],
[104.0, 0.0],
[105.0, 1.0]
]
},
"properties": {
"prop0": "value0",
"prop1": 0.0
}
type
is always Feature
.geometry
member SHALL be either a Geometry object as defined above or a JSON null value (in the case that the Feature is unlocated).properties
member is an object (any JSON object or a JSON null value).If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of the Feature object with the name id
, and the value of this member is either a JSON string or number.
A FeatureCollection object has two members: type
and features
:
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [102.0, 0.5]
},
"properties": {
"prop0": "value0"
}
}]
}
type
is always FeatureCollection
feature
is a JSON array. Each element of the array is a Feature object as defined above. It is possible for this array to be empty.A GeoJSON object MAY have a member named bbox
to include information on the coordinate range for its Geometrys, Features, or FeatureCollections.
{
"type": "FeatureCollection",
"bbox": [100.0, 0.0, 105.0, 1.0],
"features": [
//...
]
}
Reference: