Skip to contents

Classes for GeoJSON to make working with GeoJSON easier

Package API

GeoJSON objects:

The above are assigned two classes. All of them are class geojson, but also have a class name that is geo plus the name of the geometry, e.g., geopolygon for polygon.

GeoJSON properties:

GeoJSON operations:

  • geo_bbox - calculate a bounding box for any GeoJSON object

  • geo_pretty - pretty print any GeoJSON object

  • geo_type - get the object type for any GeoJSON object

  • geo_write - easily write any GeoJSON to a file

  • More complete GeoJSON operations are provdied in the package geoops

GeoJSON/Geobuf serialization:

Coordinate Reference System

According to RFC 7946 (https://datatracker.ietf.org/doc/html/rfc7946#page-12) the CRS for all GeoJSON objects must be WGS-84, equivalent to urn:ogc:def:crs:OGC::CRS84. And lat/long must be in decimal degrees.

Given the above, but considering that GeoJSON blobs exist that have CRS attributes in them, we provide CRS helpers in this package. But moving forward these are not likely to be used much.

Coordinate precision

According to RFC 7946 (https://datatracker.ietf.org/doc/html/rfc7946#section-11.2) consider that 6 decimal places amoutns to ~10 centimeters, a precision well within that of current GPS sytems. Further, A GeoJSON text containing many detailed Polygons can be inflated almost by a factor of two by increasing coordinate precision from 6 to 15 decimal places - so consider whether it is worth it to have more decimal places.

Author

Scott Chamberlain, Jeroen Ooms