I made a cool map once by plotting kml coordinates in R, and overlaying species abundance data on top. When I wrote the code the first time, I used the following to call my list of coordinates:
spa<-getKMLcoordinates('Perimeter_Track.kml', ignoreAltitude=TRUE)
summary(spa) returns:
Length Class Mode
[1,] 128 -none- numeric
[2,] 242 -none- numeric
[3,] 34 -none- numeric
[4,] 126 -none- numeric
(the GPS coordinates were a perimeter track measured in 4 chunks, so each list is one of those chunks):
NOW when I run the code again, summary(spa) returns:
Length Class Mode
[1,] 2 -none- list
[2,] 2 -none- list
[3,] 2 -none- list
[4,] 2 -none- list
If I convert spa into a dataframe using as.data.frame(), I still get this error when I try to use rbind to concatenate the 4 chunks into one big track:
Error in match.names(clabs, names(xi)) :
names do not match previous names
R seems not to be reading the kml file, or only reading part of it.
The list (or dataframe) spa is
c..157.80736808..21.4323436..20.324951171875.
1 -157.80737
2 21.43234
3 20.32495
c..157.80738216..21.43231443..19.36376953125.
1 -157.80738
2 21.43231
3 19.36377
c..157.80533605..21.43536092..15.9990234375. c..157.8053208..21.43541138..15.9990234375.
1 -157.80534 -157.80532
2 21.43536 21.43541
3 15.99902 15.99902
c..157.80998348..21.43706806..15.9990234375.
1 -157.80998
2 21.43707
3 15.99902
c..157.80997007..21.43711106..17.441162109375.
1 -157.80997
2 21.43711
3 17.44116
c..157.81074733..21.43717535..13.5958251953125.
1 -157.81075
2 21.43718
3 13.59583
c..157.81071673..21.43718331..14.076416015625.
1 -157.81072
2 21.43718
3 14.07642
Is this an error with maptools or my code? As far as I know, this is the easiest way to convert kml coordinates into coordinates that R can use. Your help would be much appreciated.
A link to the file is here: https://www.dropbox.com/s/y8elanjnst6438v/Perimeter_Track.kml
The fix has been committed to R-forge, maptools project, revision 232. Please try out after this evening European time:
which handles this problem. However, I have no idea why you didn’t use:
This is a SpatialLinesData Frame, that can be used in lots of ways with no further effort. It also tackles the tabs without difficulty. To get to your input into the form returned by the ad-hoc maptools function, do: