https://sjp.co.nz/projects/grimport2/grImport2.html
This is to import SVG graphics into R.
Reading about this has revealed at key point:
"A complication with SVG is that unlike PostScript and PDF it does not require the use of a physical coordinate system (e.g. points). This, among other things (such as attribute precedence), complicates the process of importing an SVG image. However, if we restrict the SVG we support to the SVG that is generated by the Cairo graphics library [10], then we know that the SVG images that we import are guaranteed to belong to a common coordinate system and other features of the image will be flattened, making it easier to parse. In particular, this means that grImport2 does not need to parse all of the SVG image format, only the subset of SVG that Cairo generates. Furthermore, because Cairo is is a supported graphics renderer for many open source libraries that import vector images, we know that it is possible for many input formats to be mapped to the Cairo SVG subset of SVG."
Thus there is more than one kind of SVG!
Work flow seems to be:
R> # Converting the image R> library(grConvert) R> convertPicture("nzflag-original.svg", "nzflag-cairo.svg") R> # Reading it into R R> library(grImport2) R> nzflag <- readPicture("nzflag-cairo.svg")
So convertPicture() into cairo svg first and then readPicture()
Got to be worth trying...
No comments:
Post a Comment