Manage coordinate precision
mainGeoJSON objects in this library round coordinates to a specific number of decimal places.
- Per-instance precision: Pass a
precisionargument when instantiating an object. - Package-level precision: Set
geojson.geometry.DEFAULT_PRECISIONto change the default rounding for the entire package.
Note: Setting DEFAULT_PRECISION also affects the rounding behavior when using geojson.load or geojson.loads. A common pattern to scale down precision for large datasets is to perform a load/loads followed by a dump/dumps.
from geojson import Point
import geojson
# Per-instance precision
point = Point((-115.12341234, 37.12341234), precision=8)
# Package-level precision
geojson.geometry.DEFAULT_PRECISION = 5
point_default = Point((-115.12341234, 37.12341234))