[R-sig-Geo] reading kmz file in R

Hans-Jörg Bibiko bibiko at eva.mpg.de
Mon Jun 7 14:56:21 CEST 2010


On Jun 7, 2010, at 2:23 PM, Hans-Jörg Bibiko wrote:
> On Jun 7, 2010, at 1:36 PM, Heuvelink, Gerard wrote:
> I used 'Add polygon' in Google Earth to create a (single)  closed polygon. It was saved with extension kmz.
>> 
>> How can I open such a file in R, such that I can for instance do an overlay with raster maps (SpatialGridDataFrame)?
> 
> Here only my first thoughts:
> kmz files are nothing else then zipped kml files. You can save your polygon in Google Earth by choosing "kml" as format, or unzip your kmz file and rename it to *.kml, or read the kmz as zip connection in R and process the data coming from that connection.

Here a tiny R example:

library(maptools)
getKMLcoordinates(textConnection(system("unzip -p /Users/foo/test.kmz", intern = TRUE)))

--Hans


More information about the R-sig-Geo mailing list