SCM

Forum: help

Monitor Forum | Start New Thread Start New Thread
plotKML failing for lines out near the antimeridian [ Reply ]
By: Anthony Fischach on 2016-04-21 21:46
[forum:43159]

plotKML_problem.zip (3) downloads
My SpaitialLines

(a National Ice Center Marginal Ice Zone chart cast as SpatialLines;
with a proj4strin= CRS(" +proj=aeqd +lat_0=70 +lon_0=-170 +x_0=0
+y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84
+towgs84=0,0,0 ") ;
attached as an .rData set)

near and across the antimeridian fail to plot with the plotKML::kml_layer function.

When I plot it directly in base R using the following console commands.
> plot(MIZ_m.l.c.studyArea)
> lines(MIZ_p.l.c.studyArea, lwd=1.5, col='red')
> plot(landAll, add = T, col='darkgreen')
> plot(landAll.StudyArea, add = T, col='darkgreen')
I get the attached plot (baseRplot.png).

When I cast these spatialLines to a kmz (attached) using the code below, I get only a small number of the lines over in the kmz file.

Please advise. I have tried offering the spatialLines in WGS84 geographic coordinates, both centered on Greenwich and run through maptools::Recenter, and received the same result.
Is this an issue of having multi-line SpatialLines?




plotKML code block:

MIZkml<-format(Today, 'NIC_MIZ_Line_%Y%j.kml') ## Build the name for the MIZkml file
setwd(LocalWork) ## Set the working directory so that plotKML function correctly.
kml_open(file.name= MIZkml,
folder.name = format(Today, 'NIC MIZ %d %B %Y'),
kml_visibility=TRUE) ## Open kml

kml_layer(MIZ_m.l.c.studyArea,
subfolder.name = 'NIC MIZ Marginal ice',
colour='yellow', width=2, z.scale=50000,
TimeSpan.begin=format(Today-1, '%Y-%m-%dT%H:%M:%S'),
TimeSpan.end=format(Today, '%Y-%m-%dT%H:%M:%S')) ## Plot the CT18 line


kml_layer(MIZ_p.l.c.studyArea,
subfolder.name = 'NIC MIZ Pack ice',
colour='red', width=2, z.scale=50000,
TimeSpan.begin=format(Today-1, '%Y-%m-%dT%H:%M:%S'),
TimeSpan.end=format(Today, '%Y-%m-%dT%H:%M:%S')) ## Plot the CT81 line
kml_close(file.name=MIZkml)

Thanks to:
Vienna University of Economics and Business Powered By FusionForge