Learn R Programming

maptools (version 1.1-6)

getKMLcoordinates: Get a list of coordinates out of a KML file

Description

This function parses a KML file to get the content of <coordinates> tags and returns a list of matrices representing the longitude-latitute or if ignoreAltitude is FALSE the longitude-latitute-altitude coordinates of a KML geometry.

Usage

getKMLcoordinates(kmlfile, ignoreAltitude=FALSE)

Value

coords is a list of matrices representing the longitude-latitute or if ignoreAltitude is FALSE the longitude-latitute-altitude coordinates

Arguments

kmlfile

connection object or a character string of the KML file

ignoreAltitude

if set to TRUE the altitude values of a KML points will be ignored

Author

Hans-J. Bibiko

See Also

kmlPolygon, kmlLine

Examples

Run this code
data(wrld_simpl)
## creates a KML file containing the polygons of South Africa (plus hole)
sw <- slot(wrld_simpl[wrld_simpl$NAME=="South Africa",], "polygons")[[1]]
tf <- tempfile()
kmlPolygon(sw, kmlfile=tf, name="South Africa", col="#df0000aa", lwd=5, 
    border=4, kmlname="R Test", 
    kmldescription="This is only a R test.")
zz <- getKMLcoordinates(tf, ignoreAltitude=TRUE)
str(zz)
zz <- getKMLcoordinates(system.file("shapes/Testing.kml", package="maptools"))
str(zz)

Run the code above in your browser using DataLab