Filename extensions | .json ,.geojson |
---|---|
Internet media type | application/geo+json [1] |
Type of format | GIS file format |
Extended from | JSON |
Standard | RFC 7946 |
Open format? | yes |
Website | geojson |
GeoJSON[1] is anopen standard format designed for representingsimple geographical features, along with their non-spatial attributes. It is based on theJSON format.
The features include points (therefore addresses and locations),line strings (therefore streets, highways and boundaries),polygons (countries, provinces, tracts of land), and multi-part collections of these types. GeoJSON features are not limited to representing entities of the physical world only; mobile routing and navigation apps, for example, might describe their service coverage using GeoJSON.[2]
The GeoJSON format differs from othergeographic information system standards in that it was written and is maintained not by a formal standards organization, but by an Internet working group of developers.[3]
A notable offspring of GeoJSON isTopoJSON, an extension of GeoJSON that encodesgeospatial topology and that typically provides smaller file sizes.
The GeoJSON format working group and discussion were begun in March 2007[4] and the format specification was finalized in June 2008.
In April 2015 theInternet Engineering Task Force founded theGeographic JSON working group[5] which released GeoJSON as RFC 7946 in August 2016.
{"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"}}}]}
|
Points are [x, y] or [x, y, z]. They may be[longitude, latitude] or[eastings, northings]. Elevation, in meters,[6] is an optional third number. They are decimal numbers.[7]
For example, London (51.5074° North, 0.1278° West) is [-0.1278, 51.5074]
Type | Examples | |
---|---|---|
Point | ![]() | {"type":"Point","coordinates":[30.0,10.0]} |
LineString | ![]() | {"type":"LineString","coordinates":[[30.0,10.0],[10.0,30.0],[40.0,40.0]]} |
Polygon | ![]() | {"type":"Polygon","coordinates":[[[30.0,10.0],[40.0,40.0],[20.0,40.0],[10.0,20.0],[30.0,10.0]]]} |
![]() | {"type":"Polygon","coordinates":[[[35.0,10.0],[45.0,45.0],[15.0,40.0],[10.0,20.0],[35.0,10.0]],[[20.0,30.0],[35.0,35.0],[30.0,20.0],[20.0,30.0]]]} |
Type | Examples | |
---|---|---|
MultiPoint | ![]() | {"type":"MultiPoint","coordinates":[[10.0,40.0],[40.0,30.0],[20.0,20.0],[30.0,10.0]]} |
MultiLineString | ![]() | {"type":"MultiLineString","coordinates":[[[10.0,10.0],[20.0,20.0],[10.0,40.0]],[[40.0,40.0],[30.0,30.0],[40.0,20.0],[30.0,10.0]]]} |
MultiPolygon | ![]() | {"type":"MultiPolygon","coordinates":[[[[30.0,20.0],[45.0,40.0],[10.0,40.0],[30.0,20.0]]],[[[15.0,5.0],[40.0,10.0],[10.0,20.0],[5.0,10.0],[15.0,5.0]]]]} |
![]() | {"type":"MultiPolygon","coordinates":[[[[40.0,40.0],[20.0,45.0],[45.0,30.0],[40.0,40.0]]],[[[20.0,35.0],[10.0,30.0],[10.0,10.0],[30.0,5.0],[45.0,20.0],[20.0,35.0]],[[30.0,20.0],[20.0,15.0],[20.0,25.0],[30.0,20.0]]]]} | |
GeometryCollection | ![]() | {"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[40.0,10.0]},{"type":"LineString","coordinates":[[10.0,10.0],[20.0,20.0],[10.0,40.0]]},{"type":"Polygon","coordinates":[[[40.0,40.0],[20.0,45.0],[45.0,30.0],[40.0,40.0]]]}]} |
An alternative to GeoJSON is to encode one geographic feature per line, with line breaks (or record-separator characters) designating the separation between records.
This format can be much faster more efficient to parse than normal GeoJSON, as tooling can read individual records in parallel. This format is similar tonewline-delimited JSON
Variants of newline-delimited GeoJSON include:
TopoJSON is an extension of GeoJSON that encodestopology. Rather than representing geometries discretely, geometries in TopoJSON files are stitched together from shared line segments calledarcs.[10]Arcs are sequences of points, while line strings and polygons are defined as sequences of arcs. Each arc is defined only once, but can be referenced several times by different shapes, thus reducing redundancy and decreasing the file size.[11] In addition, TopoJSON facilitates applications that use topology, such as topology-preserving shape simplification, automatic map coloring, andcartograms.
A reference implementation of the TopoJSON specification is available as a command-line tool to encode TopoJSON from GeoJSON (or ESRI Shapefiles) and aclient sideJavaScript library to decode TopoJSON back to GeoJSON again. TopoJSON is also supported by the popular OGR tool as of version 1.11[12] and PostGIS as of version 2.1.0.[13]
Given aGIS shape nearcoordinateslatitude 0° andlongitude 0°, a simple but valid and complete topojson file containing all metadata,Polygon,LineString,Point elements,arcs andproperties is defined as follows:
{"type":"Topology","transform":{"scale":[1,1],"translate":[0,0]},"objects":{"two-squares":{"type":"GeometryCollection","geometries":[{"type":"Polygon","arcs":[[0,1]],"properties":{"name":"Left_Polygon"}},{"type":"Polygon","arcs":[[2,-1]],"properties":{"name":"Right_Polygon"}}]},"one-line":{"type":"GeometryCollection","geometries":[{"type":"LineString","arcs":[3],"properties":{"name":"Under_LineString"}}]},"two-places":{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[0,0],"properties":{"name":"Origine_Point"}},{"type":"Point","coordinates":[0,-1],"properties":{"name":"Under_Point"}}]}},"arcs":[[[1,2],[0,-2]],[[1,0],[-1,0],[0,2],[1,0]],[[1,2],[1,0],[0,-2],[-1,0]],[[0,-1],[2,0]]]}