[R-sig-Geo] Reading SVG files into R (as spatial polygons/lines)

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Feb 11 13:25:56 CET 2009


2009/2/11 baptiste auguie <ba208 at exeter.ac.uk>:
> Hi,
>
> Perhaps you could try converting to postscript and then importing into R
> with the grImport package? It seems a bit redundant (the postscript is going
> to be converted back into some XML thing) but it might just work for simple
> outlines.

 And heaven only knows what projection the data will be in after
PostScript has played with it...

 You could try reading the XML and getting the coords out - but
beware! SVG can do all sorts of things. Some of the polygons in one of
the wikipedia examples I looked at are grouped into SVG <g> tags with
"translate" parameters, so all those coords need shifting. I think you
really need to process the SVG rather than try to parse it.

 I've not looked to see what the python script here does:
   http://gsl-nagoya-u.net/appendix/software/worldmap/

Barry



More information about the R-sig-Geo mailing list