{"id":2043,"library":"geojson","title":"geojson","description":"Python bindings and utilities for GeoJSON. This library provides functions for encoding and decoding GeoJSON formatted data, classes for all GeoJSON Objects as defined by the GeoJSON Format Specification, and implements the Python `__geo_interface__` Specification. It is currently at version 3.2.0 and is actively maintained by the Jazzband community, compatible with Python 3.7 and above.","status":"active","version":"3.2.0","language":"python","source_language":"en","source_url":"https://github.com/jazzband/geojson","tags":["GeoJSON","GIS","mapping","serialization","geospatial"],"install":[{"cmd":"pip install geojson","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"Point","correct":"from geojson import Point"},{"symbol":"LineString","correct":"from geojson import LineString"},{"symbol":"Polygon","correct":"from geojson import Polygon"},{"symbol":"Feature","correct":"from geojson import Feature"},{"symbol":"FeatureCollection","correct":"from geojson import FeatureCollection"},{"symbol":"dumps","correct":"from geojson import dumps"},{"note":"Using `json.loads` directly will return a plain dictionary, losing the GeoJSON object methods and attributes. Use `geojson.loads` for richer objects.","wrong":"import json; json.loads(...)","symbol":"loads","correct":"from geojson import loads"},{"symbol":"dump","correct":"from geojson import dump"},{"note":"Using `json.load` directly will return a plain dictionary, losing the GeoJSON object methods and attributes. Use `geojson.load` for richer objects.","wrong":"import json; json.load(...)","symbol":"load","correct":"from geojson import load"}],"quickstart":{"code":"from geojson import Point, Feature, FeatureCollection, dumps\n\n# Create a Point geometry\npoint = Point((-115.81, 37.24))\n\n# Create a Feature with the Point geometry and properties\nfeature = Feature(geometry=point, properties={\"name\": \"Area 51\"})\n\n# Create a FeatureCollection containing the feature\nfeature_collection = FeatureCollection([feature])\n\n# Serialize the FeatureCollection to a GeoJSON string with indentation\ngeojson_str = dumps(feature_collection, indent=2)\nprint(geojson_str)","lang":"python","description":"This quickstart demonstrates how to create common GeoJSON objects like `Point`, `Feature`, and `FeatureCollection`, and then serialize them into a GeoJSON formatted string using `geojson.dumps`."},"warnings":[{"fix":"Ensure your project uses Python 3.7+ and update any code relying on custom CRS definitions or the `geojson.crs` module.","message":"Version 3.0.0 dropped support for Python 2 and now requires Python 3.7 or newer. Additionally, the `crs` module and related features were removed to strictly conform to the official GeoJSON specification, which mandates WGS84 coordinates.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace `json.load(f)` with `geojson.load(f)` and `json.loads(s)` with `geojson.loads(s)`.","message":"When loading or decoding GeoJSON data, always use `geojson.load` or `geojson.loads` instead of the standard `json.load` or `json.loads`. Using the standard `json` module will return plain Python dictionaries, losing the rich GeoJSON object functionality and validation provided by this library.","severity":"gotcha","affected_versions":"All"},{"fix":"Adjust the `precision` attribute when creating GeoJSON objects or set `geojson.DEFAULT_PRECISION` globally if higher precision is required. Be aware that this can increase file size.","message":"GeoJSON object classes in this library apply a default coordinate precision of 6 decimal places (approximately 0.1 meters). While this is often suitable, it may lead to data loss for highly precise geospatial coordinates if not explicitly managed.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'3.2.0':43 '3.7':55 'activ':46 'bind':3 'class':19 'communiti':51 'compat':52 'current':40 'data':18 'decod':15 'defin':25 'encod':13 'format':17,29 'function':11 'geo':35 'geojson':1,7,16,22,28,58 'geospati':62 'gis':59 'implement':32 'interfac':36 'jazzband':50 'librari':9 'maintain':47 'map':60 'object':23 'provid':10 'python':2,34,54 'serial':61 'specif':30,37 'util':5 'version':42","created_at":"2026-04-09T18:41:04.632882+00:00","updated_at":"2026-04-16T15:14:55.079225+00:00","problems":[{"fix":"Install the package using pip: `pip install geojson` (or `pip3 install geojson` for Python 3 specific installations).","cause":"The 'geojson' library is not installed in the Python environment where you are running your code, or the environment is not correctly activated.","error":"ModuleNotFoundError: No module named 'geojson'"},{"fix":"Ensure the coordinates for a `Polygon` are a list of lists of `(longitude, latitude)` tuples. For a simple polygon, it should be `[[exterior_ring_coords]]`. Example: `geojson.Polygon([[(0, 0), (1, 1), (1, 0), (0, 0)]])`","cause":"This error occurs when creating a `geojson.Polygon` object because the coordinates are not nested correctly according to the GeoJSON specification. A Polygon's coordinates should be a list of linear rings, where each linear ring is itself a list of coordinate pairs, and the first and last coordinate pair of each linear ring must be identical. A common mistake is providing a single linear ring as a direct list of points instead of a list containing that list.","error":"ValueError: Expected 0 or more linear rings, got (...)"},{"fix":"If you have a GeoJSON string, you need to parse it into a Python GeoJSON object (or a Shapely geometry object) before using it in operations that expect a geometry. Use `geojson.loads(json_string)` to get a `geojson` object, or `shapely.geometry.shape(geojson.loads(json_string))` to get a Shapely object.","cause":"This error typically arises when you are attempting to perform a geospatial operation (often with a library like Shapely) that expects a geometry object, but you are instead providing a raw GeoJSON string. The `_geom` attribute is internal to some geometry libraries and is not present on a standard Python string.","error":"AttributeError: 'str' object has no attribute '_geom'"},{"fix":"Create a `folium.GeoJson` object separately and then add it to your map instance. Example: `geojson_data = geojson.loads(my_geojson_string)`; `folium.GeoJson(geojson_data).add_to(my_map)` or `my_map.add_child(folium.GeoJson(geojson_data))`.","cause":"This error occurs when attempting to add GeoJSON data to a Folium map using a non-existent method or attribute. In Folium, `GeoJson` is a separate class used to create a GeoJSON layer, which is then added to the map using `add_to()` or `add_child()`, not by directly accessing an attribute on the map object.","error":"AttributeError: 'Map' object has no attribute 'GeoJson'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.3.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/jazzband/geojson","docs":null,"changelog":null,"pypi":"https://pypi.org/project/geojson/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}