Classes for GeoJSON to make working with GeoJSON easier
Package API
GeoJSON objects:
feature
- Featurefeaturecollection
- FeatureCollectiongeometrycollection
- GeometryCollectionlinestring
- LineStringmultilinestring
- MultiLineStringmultipoint
- MultiPointmultipolygon
- MultiPolygonpoint
- Pointpolygon
- Polygon
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:
properties_add
,properties_get
- Add or get properties
GeoJSON operations:
geo_bbox
- calculate a bounding box for any GeoJSON objectgeo_pretty
- pretty print any GeoJSON objectgeo_type
- get the object type for any GeoJSON objectgeo_write
- easily write any GeoJSON to a fileMore complete GeoJSON operations are provdied in the package geoops
GeoJSON/Geobuf serialization:
from_geobuf
- Geobuf to GeoJSONto_geobuf
- GeoJSON to GeobufCheck out https://github.com/mapbox/geobuf for inormation on the Geobuf format
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.