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 name 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 placemarkers name and their latitude, longitude and altitude coordinates
- Exports a csv file named coordinates, which has all placemarkers name, their x, y and z coordinates
In order 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 at 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 longitute and x,y,z coordinates.
Notes!
- To add full fillpath for example if the kml file is in your Desktop the command should look like this:
python extractData.py "C:\Users\User\Desktop\example.kml"
- The csv files will be located at the same folder as 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: Optimazation Algorithms
KEYWORDS: Python, KML, Data extraction, Transform coordinates to xyz