This tool is designed to extract polygon coordinates from KML files. KML (Keyhole Markup Language) files are XML-based and often used for geographical data. This script parses these files to find and extract coordinates of enclosed polygons, particularly useful for polygons drawn in Google Earth.
- Extracts coordinates of polygons from KML files.
- Outputs coordinates as a JavaScript variable.
- Automatically copies the output to the clipboard for easy use.
- Clone this repository.
git clone https://github.com/patpragman/shapefl.gitand navigate to the newly created directory - Create a virtual environment named
venvon linux:python3 -m venv venv. - Install the required dependencies.
pip install -r requirements.txt
Run the script using the following command:
source geoconf.bash --input_file /path/to/kml_file.kml
The script will output the coordinates as a JavaScript variable and copy them to the clipboard.
var roi = ee.Geometry.Polygon([ [[-122.45, 37.74], [-122.45, 37.8],
[-122.4, 37.8], [-122.4, 37.74], [-122.45, 37.74]]
]);The script is designed for simple polygons. It might not work as expected with complex topologies.
Thanks to ChatGPT for assistance in understanding KML structures and initial code generation.
- Pat Pragman
Feel free to contribute, report issues, or suggest improvements.