kml2geojson is a Python 3.8+ package to convert KML files to GeoJSON files. Most of its code is a translation into Python of the Node.js package togeojson, but kml2geojson also adds the following features.
- Preserve KML object styling, such as color and opacity
- Optionally create a style dictionary cataloging all the KML styles used
- Optionally create several GeoJSON FeatureCollections, one for each KML folder present
Create a Python 3.8+ virtual environment and run
poetry add kml2geojson.
Use as a library or from the command line.
For instructions on the latter, type
docs directory and published at mrcagney.github.io/kml2geojson_docs.
- Development status is Alpha.
- This project uses semantic versioning.
- Thanks to MRCagney for funding this project.
- Alex Raichev (2015-10-03), maintainer
If you want to help develop this project, here is some background reading.
convert()to accept a KML file object.
- Added type hints.
- Updated dependencies and removed version caps.
- Dropped support for Python versions less than 3.8.
- Switched from Travis CI to Github Actions.
- Re-included the MIT License file and added more metadata to the file
pyproject.tomlfor a more informative listing on PyPi.
- Upgraded to Python 3.9 and dropped support for Python versions < 3.6.
- Switched to Poetry.
- Breaking change: refactored the
convertfunction to return dictionaries instead of files.
- Moved docs from Rawgit to Github Pages.
- Fixed the bug where
setup.pycould not find the license file.
- Moved the name of a FeatureCollection into a 'name' attribute, because RFC 7946 says that a GeoJSON FetaureCollection must not have a 'properties' attribute
- Stripped leanding and trailing whitespace from text content to avoid cluttered or blank name and description attribute values
- Switched to pytest for testing
- Moved command line functionality to separate module
- Renamed some functions
Disambiguated filenames in
to_filename() and removed the lowercasing.
to_filename() to lowercase and underscore results.
Forgot to do that last time.
Changed the output of
build_layers() and moved layer names into the GeoJSON FeatureCollections
- Replaced underscores with dashes in command line options
- Set default border style for colored polygons
- Added documentation
- Tweaked the command line tool options
- Changed some names
- Added lots of tests
Fixed packaging to find