1

I am trying to export shapefile data from GIS to KML with R and want to specify the appearance of the pop-up window of the KML file when using it in Google Earth. I know of course that it's easily possible within the GIS programs but want to do it with R.

The example below works fine but the pop-up windows don't really look good.

library(raster)
library(plotKML)
library(colorRamps)

col <- getData(country = "COL", level = 1)

kml_open("colombia.kml")
kml_layer(obj = col, 
      folder.name = "testData",
      altitude = 100,
      plot.labpt = F,
      html.table = paste("Info 1: ",as.character(col@data$NAME_1),"  ||  ",
                          "Info 2: ",as.character(col@data$HASC_1),"  ||  ",
                          "Info 3: ",as.character(col@data$NAME_0),"  ||  ",
                          "Info 4: ",as.character(col@data$TYPE_1),"  ||  ",
                          "Info 5: ",as.character(col@data$ENGTYPE_1)))

kml_close("colombia.kml")

I would like specify line breaks e.g. "\n" instead of " || " but that doesn't work with paste. The function cat, where "\n" works fine, doesn't seem to work within the html.table command.

I didn't find any further information or examples regarding the html.table command in the kml_layer function and also tried to solve my problem with the htmlTable-package but didn't have success.

Does anyone have a tip or link with information to solve it?

1

The simplest way to insert linebreaks in your KML balloon content is to use HTML <br> tags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.