Detailed description |
Not sure if this is a bug but it seems to be. It occurs when you try to plot a STIDF object that contains a polygon with a hole and both a start and end timestamp. You will get an error like this:
Reprojecting to +proj=longlat +datum=WGS84 ...
Writing to KML...
Error in sprintf("<Placemark><name>%s</name><styleUrl>#poly%s</styleUrl><TimeSpan><begin>%s</begin><end>%s</end></TimeSpan><Polygon><extrude>%.0f</extrude><tessellate>%.0f</tessellate><altitudeMode>%s</altitudeMode><outerBoundaryIs><LinearRing><coordinates>%s</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark>", :
arguments cannot be recycled to the same length
It seems that the culprit is the last sprintf which incorrectly passes TimeSpan.begin and TimeSpan.end instead of the expanded TimeSpan.begin.l, and TimeSpan.end.l. The fixed line should read:
txt <- sprintf("<Placemark><name>%s</name><styleUrl>#poly%s</styleUrl><TimeSpan><begin>%s</begin><end>%s</end></TimeSpan><Polygon><extrude>%.0f</extrude><tessellate>%.0f</tessellate><altitudeMode>%s</altitudeMode><outerBoundaryIs><LinearRing><coordinates>%s</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark>",
unlist(poly_names.l), 1:sum(unlist(pvn)), unlist(TimeSpan.begin.l),
unlist(TimeSpan.end.l), rep(as.numeric(extrude), sum(unlist(pvn))),
rep(as.numeric(tessellate), sum(unlist(pvn))),
rep(altitudeMode, sum(unlist(pvn))), paste(unlist(coords)))
Dave |
|