Description Usage Arguments Details Value Examples

Convert a SVG file to a spatstat psp object.

1 2 3 |

`file` |
File path of the svg file to convert. |

`bezier` |
Parameters for approximating bezier curves (see Details). |

`owin` |
Specify a window for the |

`marks` |
Add marks to segments (see details). |

`connect` |
Assign segments to sets depending on their distance and orientation. |

`upward, rightward` |
directions of the segments (see details). |

`reverse` |
Define the position of the origin of the |

`rescale` |
rescale |

`...` |
Arguments passed to cut.psp or connectedsets.psp. |

This functions provide a way to import SVG files in R to use with spatstat. Only absolute and relative SVG paths `moveto`

, `lineto`

, and `curveto`

(quadratic and cubic bezier) are implemented at the moment.
There seem to be a wide range of interpretations of the W3C SVG specifications, so import is not completely guaranteed. Package tested with SVG produced by `autotrace`

(http://autotrace.sourceforge.net/) and `Inkscape`

(https://inkscape.org/, Save as Plain SVG).

Bezier quadratic and cubic curves are approximated using the De Casteljau algorithm. Quadratic bezier curves are first approximated by a cubic bezier curves. If `bezier`

=0, bezier curves are converted to bezier polygons (i.e. goes through all control points). If `bezier`

>0, Bezier curves are approximated by linear segments. The value of the parameter is the number of iterations used in the approximation (see https://en.wikipedia.org/wiki/De_Casteljau's_algorithm for details).

The resulting `psp`

can have marks attached. If `marks=1`

, segments of the `psp`

have a numeric mark depending on the SGV path they belong to. If `marks=2`

, all segments have a numeric mark depending on the SVG command that created them. If `marks=3`

, all segments have a unique mark (for debug purposes). Defaults to `marks=0`

which results in an unmarked `psp`

. If `marks`

is a character, then marks will be read from the corresponding field in the svg file.

If `connect=T`

, the resulting `psp`

is processed through connectedsets.psp. The resulting `psp`

will be a marked psp with each mark corresponding to a set.

Parameters `upward`

and `rightward`

allow to alter the orientation of segments of the `psp`

. If both are `F`

, detected segments have the orientation they have in the SVG file. If `upward=T`

, the direction of of segments is flipped so that all segments will point towards increasing values of the *y* direction. If `rightward=T`

, the direction of of segments is flipped so that all segments will point towards increasing values of the *x* direction.

The `reverse`

parameter determines the position of the origin of the `psp`

. `reverse = F`

(default) considers the origin at the bottom left of the SVG. `reverse=T`

puts the origin of the image at the top left, as in SVG files.

Some SVG file contains size information. `rescale`

determines whether the resulting `psp`

dimensions are expressed in pixel units (`rescale=F`

, *default*) or in the units of the SVG file (`rescale=T`

, if available).

A (marked) `psp`

object

1 2 3 4 5 6 |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.