Dnia 2010-11-26, o godz. 17:11:22 Barry Rowlingson <b.rowling...@lancaster.ac.uk> napisaĆ(a):
> On Fri, Nov 26, 2010 at 5:03 PM, fbielejec <fbiele...@gmail.com> > wrote: > > Dear, > > > > I would like to generate kml file with lines (<LineString>) of > > different style (definitely color, but width would also be nice to > > see). However with kmlLine from maptools package I am able only to > > output the single first Lines object (first row of > > SpatialLinesDataFrame) > > > > I guess the option would be to have single Lines object (instead of > > list of them), but then also the style wouldn't vary among them... > > My code so far: > > If you cant get what you want from package code, and you know a bit > about the KML format you are trying to produce, then try using the R > 'brew' package, which lets your write a template which can have loops, > variable substitutions, and other bits of R code in it. > > For example, here creating a simple set of KML points from a data > frame called 'cpts': > > <?xml version="1.0" encoding="UTF-8"?> > <kml xmlns="http://earth.google.com/kml/2.1"> > <Document> > <% for(i in 1:nrow(cpts)){ %> > <Placemark> > <Name><%=paste("pt-",i,sep="")%></Name> > <Point> > <coordinates><%=cpts[i,]$Xt%>,<%=cpts[i,]$Yt%>,0</coordinates> > </Point> > </Placemark> > <% } %> > </Document> > </kml> > > > results in a KML with lots of these: > > <Placemark> > <Name>pt-4</Name> > <Point> > <coordinates>-43.93769,-19.92065,0</coordinates> > </Point> > </Placemark> > > - its a lot easier than writing lots of cat() and other formatting > nonsense in R code! > > But if you can get package code to do it, that's the way to go. But > for outside-the-box solutions, install.packages("brew")! > > Barry Dear, Many thanks, that indeed is an option. However we already have a software in our lab that works in a similar way, writing lines of kml code to files, I was hoping to write something more generic... -- while(!succeed) { try(); } ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.