{"id":24185,"library":"osm2geojson","title":"osm2geojson","description":"A Python library to convert OSM and Overpass JSON responses into valid GeoJSON. Version 0.3.2 is the latest stable release. The library is actively maintained, with recent bug fixes for polygon hole handling and blacklist/whitelist rules. Releases are sporadic.","status":"active","version":"0.3.2","language":"python","source_language":"en","source_url":"https://github.com/aspectumapp/osm2geojson","tags":["osm","overpass","geojson","gis","converter"],"install":[{"cmd":"pip install osm2geojson","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"optional dependency for Overpass API queries","package":"overpy","optional":true}],"imports":[{"note":null,"wrong":null,"symbol":"osm2geojson","correct":"import osm2geojson"}],"quickstart":{"code":"import osm2geojson\n\n# Example: convert an Overpass JSON response to GeoJSON\noverpass_json = {\n    \"elements\": [\n        {\n            \"type\": \"node\",\n            \"id\": 1,\n            \"lat\": 50.0,\n            \"lon\": 10.0,\n            \"tags\": {\"amenity\": \"cafe\"}\n        }\n    ]\n}\n\ngeojson = osm2geojson.json2geojson(overpass_json)\nprint(geojson)","lang":"python","description":"Converts an OSM JSON dict (e.g., from Overpass API) into a GeoJSON FeatureCollection."},"warnings":[{"fix":"Ensure you pass a dict via json.loads() if reading from a string.","message":"Input must be a parsed JSON dict, not a raw string. If you pass a string, the function will fail.","severity":"gotcha","affected_versions":"all"},{"fix":"Validate your Overpass JSON structure before passing to osm2geojson.","message":"The 'elements' key in Overpass JSON is required. If your JSON is malformed (e.g., missing 'elements'), the conversion will return an empty FeatureCollection.","severity":"gotcha","affected_versions":"all"},{"fix":"Use json2geojson instead of overpass2geojson.","message":"The function 'overpass2geojson' in older versions is deprecated in favor of 'json2geojson'. Using the old name may raise a deprecation warning or be removed.","severity":"deprecated","affected_versions":"<0.3.0"},{"fix":"Post-process with a polygon winding fixer if required by your GeoJSON consumer.","message":"Polygon orientation (clockwise/counter-clockwise) is not automatically corrected. The library follows the OSM convention, which may produce invalid GeoJSON if the winding order is wrong.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use osm2geojson.json2geojson(data) instead of osm2geojson.overpass2geojson(data).","cause":"The function 'overpass2geojson' was renamed to 'json2geojson' in version 0.3.0.","error":"AttributeError: module 'osm2geojson' has no attribute 'overpass2geojson'"},{"fix":"Check your JSON structure; ensure it has an 'elements' list. If from Overpass, use the raw response (the JSON output from the API).","cause":"The input JSON dict does not contain the expected 'elements' key. The library expects the standard Overpass JSON format.","error":"KeyError: 'elements'"},{"fix":"Pass the dict directly to osm2geojson.json2geojson(dict). If you have a string, do: geojson = osm2geojson.json2geojson(json.loads(json_string)).","cause":"The user passed a Python dict without calling json2geojson, but tried to use json.loads on an already-parsed dict.","error":"TypeError: the JSON object must be str, bytes or bytearray, not dict"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}