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

baptiste auguie ba208 at exeter.ac.uk
Wed Feb 11 10:41:09 CET 2009


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.

Paul Murrell has a tutorial for this,

http://www.stat.auckland.ac.nz/~paul/R/grImport/import.pdf

(I haven't tried it for SVG pictures)

Hope this helps,

baptiste

On 11 Feb 2009, at 09:22, Hengl, T. wrote:

>
> Dear list,
>
> I discovered recently that Wikipedia has an extensive list of  
> various administrative/political/thematic/historic maps (which are  
> regularly updated!):
>
> http://en.wikipedia.org/wiki/Wikipedia:Blank_maps
>
> The maps are provided in PNG and SVG (Scalable Vector Graphics)  
> formats. The later being recently promoted as the most prefer format  
> for web-graphics (I completely agree). The SVG format is a type of  
> XML, thus it can be directly read to R using the XML package. If I  
> look at the elements of e.g. http://upload.wikimedia.org/wikipedia/commons/0/03/BlankMap-World6.svg 
>  map, I can see that a polygon is coded as:
>
> ----------------------------------------------
> ...
> <g id='fr'>
>                <g class='landxx coastxx fr fx' id='fx'>
>                        <path d='M 1258.5363,351.42953 C  
> 1258.2153,351.09353 1257.8553,350.80453 1257.4563,350.56553 C  
> 1257.5503,351.13153 1257.9293,351.52653 1258.5363,351.42953'  
> id='path2166'/>
> ...
> ----------------------------------------------
>
> which is some small polygon of France. So these are obviously  
> coordinates (the Robinson projection system) of the nodes of that  
> polygon and "id" is it's unique ID.
>
> The issue is how to read a SVG into a GIS/R (see also http://wiki.svg.org/GIS_in_SVG)? 
>  I could not find any 'easy way' do this, although it seems that  
> conversion SVG to GML and then to OGR formats should go easy. I  
> guess that it should not be too complicated to sort all polygons and  
> create a "SpatialPolygonsDataFrame". Did anybody already try  
> something similar?
>
>
> Thanks!
>
> Tom Hengl
> http://spatial-analyst.net
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag



More information about the R-sig-Geo mailing list