Skip to main content
GeoJSON is a textual data format for representing spatial information. It is based on JavaScript Object Notation (JSON). GeoJSON can be used to represent the following spatial objects, which also have and representations:
  • Point
  • LineString
  • Polygon
  • MultiPoint
  • MultiLineString
  • MultiPolygon
  • GeometryCollection
GeoJSON introduces the following additional concepts, which are not part of WKT or WKB:
  • A “Feature” object that can contain a geometric shape and some additional properties that describe that shape. This is useful, for example, when drawing maps on the internet in color, such as on geojson.io. For an example showing how to add color to a GeoJSON feature, see below.
  • Features can additionally be grouped together into a “FeatureCollection”.
For more detailed information, see the GeoJSON RFC.
GeoJSON should only be used for spatial data that uses the geographic spatial reference system. For more information, see .

Example

In the example below, we will convert a shape represented in to GeoJSON using the ST_AsGeoJSON . Here is the WKT:
Convert it to GeoJSON using the ST_AsGeoJSON function:
This is the JSON output of the above, but formatted:
The JSON below is modified from the output above: it is grouped into a GeoJSON FeatureCollection in which each Feature has additional styling information (in the properties field) that can be used in visualization tools such as geojson.io:
Here is the geometry described above as shown on geojson.io: GeoJSON.io output

See also