This project was created during my studies at the University for the course "Optimization Algorithms". The final assignment required us to use optimization algorithms to find a solution to a similar postman problem with coordinates from a KML file. This Python script can export the placemarks' names and coordinates (latitude and longitude) to a CSV file as well as convert the latitude and longitude to x, y, and z coordinates, creating a second CSV file with them.
- Exports a CSV file named rawcoordinates, which has all placemarks' name and their latitude, longitude, and altitude coordinates
- Exports a CSV file named coordinates, which has all placemarks names, their x, y, and z coordinates
To run the application locally, you should have the following installed:
- Python 3.9.6 (Download here)
- defusedxml module
pip install defusedxml
- Download the Python file (extractData.py) and add it to the folder where your KML file is (or not)
- In your terminal window, move to where you downloaded the extractData.py
- Then run the following command:
python extractData.py "example.kml"
- The script will extract and create the CSV files with the latitude and longitude and x,y,z coordinates.
Notes!
- To add full fillpath, for example,e if the KML file is on your Desktop, the command should look like this:
python extractData.py "C:\Users\User\Desktop\example.kml"
- The CSV files will be located in the same folder as the extractData.py file
- The default namespace is: http://www.opengis.net/kml/2.2, but if you want to use another, then you can use the -n/--namespace flag. The command with -n flag looks like this:
python extractData.py "C:\Users\User\Desktop\example.kml" -n "http://www.opengis.net/kml/2.2"
See LICENSE
SUBJECT AREA: Optimization Algorithms
KEYWORDS: Python, KML, Data extraction, Transform coordinates to xyz
