-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcsv_to_kml_converter.py
More file actions
34 lines (25 loc) · 875 Bytes
/
Copy pathcsv_to_kml_converter.py
File metadata and controls
34 lines (25 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import csv
import simplekml
def convert_csv_to_kml(csv_file, kml_file):
# Create a KML object
kml = simplekml.Kml()
# Open the CSV file
with open(csv_file, 'r') as file:
reader = csv.reader(file)
# Skip the header row
next(reader)
# Iterate over the remaining rows
for row in reader:
well_name = row[0]
latitude = float(row[1])
longitude = float(row[2])
status = row[3]
# Create a KML placemark for each well
placemark = kml.newpoint(name=well_name, coords=[(longitude, latitude)])
placemark.description = status
# Save the KML file
kml.save(kml_file)
# Provide the path to your CSV file and desired output KML file
csv_file = 'path/to/input.csv'
kml_file = 'path/to/output.kml'
convert_csv_to_kml(csv_file, kml_file)