{"id":21504,"library":"kml2geojson","title":"KML to GeoJSON","description":"kml2geojson is a Python library that converts KML files to GeoJSON format. Current version is 5.1.1. Actively maintained.","status":"active","version":"5.1.1","language":"python","source_language":"en","source_url":"https://github.com/araichev/kml2geojson","tags":["kml","geojson","conversion","gis"],"install":[{"cmd":"pip install kml2geojson","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"Function convert is not a top-level attribute of the module.","wrong":"import kml2geojson","symbol":"convert","correct":"from kml2geojson import convert"}],"quickstart":{"code":"from kml2geojson import convert\nimport os\n\nkml_path = 'path/to/file.kml'\nif not os.path.exists(kml_path):\n    print(\"KML file not found.\")\nelse:\n    geojson = convert(kml_path)\n    # geojson is a dict that can be written as GeoJSON\n    import json\n    with open('output.geojson', 'w') as f:\n        json.dump(geojson['features'] if 'features' in geojson else geojson, f)","lang":"python","description":"Convert a KML file to GeoJSON object."},"warnings":[{"fix":"Update code to handle return value as dict.","message":"Version 5.0.0 changed input/output: convert() now returns a dict instead of writing to file. Old code that expected file output will break.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Write XML string to a temporary file or use io.StringIO with proper encoding.","message":"Input KML must be a file path or file-like object. Direct XML strings are not supported.","severity":"gotcha","affected_versions":"all"},{"fix":"Use Python 3.11 or newer.","message":"Python 3.11 minimum is required in version 5.1.1. Older versions (pre-5.0) supported Python 3.6+.","severity":"deprecated","affected_versions":">=5.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Pass a file path string to convert(), not a parsed KML dict.","cause":"convert() takes a file path, not a dict.","error":"TypeError: expected str, bytes or os.PathLike object, not dict"},{"fix":"Check the structure: geojson['features'] if 'features' in geojson else geojson.","cause":"Output may not have a 'features' key if the GeoJSON is a single feature or non-standard.","error":"KeyError: 'features'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}