-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsv2kml.pl
64 lines (58 loc) · 1.42 KB
/
csv2kml.pl
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/perl
# Purpose: This useful script converts a CSV file to a KML file
# Usage: perl csv2kml.pl < in.csv > out.kml
print '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>
<ScreenOverlay>
<name></name>
<visibility>1</visibility>
<overlayXY x="0" y="-1" xunits="fraction" yunits="fraction"/>
<screenXY x="0" y="0" xunits="fraction" yunits="fraction"/>
<rotationXY x="0" y="0" xunits="fraction" yunits="fraction"/>
<size x="0" y="0" xunits="fraction" yunits="fraction"/>
</ScreenOverlay>
<StyleMap id="">
<Pair>
<key>normal</key>
<styleUrl></styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl></styleUrl>
</Pair>
</StyleMap>';
while (<>) {
s/\&/\&/g;
@a=split /,/;
print "<Style id="">
<IconStyle>
<Icon>
<scale>1.1</scale>
<href></href>
</Icon>
</IconStyle>
<LabelStyle>
<scale>0</scale>
</LabelStyle>
</Style>
<Style id="">
<IconStyle>
<Icon>
<scale>1.1</scale>
<href></href>
</Icon>
</IconStyle>
<LabelStyle>
<scale>0</scale>
</LabelStyle>
</Style>
<Placemark>
<styleUrl></styleUrl>
<name>$a[14]</name>
<description>$a[16]</description>
<Point><coordinates>$a[6],$a[5],0</coordinates></Point>
</Placemark>"
};
print '</Document>
</kml>';