pointsvg: Converts line, rect, polygon and polyline class SVG objects...

Description Usage Arguments Details Value See Also Examples

View source: R/pointsvg.R

Description

Converts 'line', 'rect', 'polygon' and 'polyline' class SVG objects into data frames. ONLY THESE CLASSES OF OBJECTS CAN BE IMPORTED. If you have bezier or spline curves, they will be stored as 'path' class objects that cannot be imported here. The same goes for 'rect' objects that are transformed (rotation, etc...).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
pointsvg(
  file,
  standard = TRUE,
  keep.ratio = FALSE,
  round = TRUE,
  xdigits = 4,
  ydigits = 4,
  xinverse = FALSE,
  yinverse = TRUE,
  warn = T
)

Arguments

file

a .svg file

standard

whether to standardise (centre to (0,0), rescale so that extreme points are at -1 and 1) (T or F)

keep.ratio

if the object is to be standardised, whether to keep the x/y ratio (T or F)

round

whether to round the coordinates (T or F)

xdigits

the number of digits after the decimal to round to for x values

ydigits

the number of digits after the decimal to round to for y values

xinverse

whether to inverse the plotting for x values (T or F)

yinverse

whether to inverse the plotting for y values (T or F)

warn

whether you want to be annoyed

Details

This function is quite empirical. There is no guarantee it is bug free. If you have .svg files that should work but do not, you can email me: s├ębastien.wouters@doct.uliege.be

Value

A data.frame with x and y coordinates, ids for each object, and a type, either line (L) or polygon (P)

See Also

Plot the drawing: placesvg,

Plot the drawing and change the coordinates :centresvg and framesvg

Change the drawing: changesvg and clipsvg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# To show you how to import, we first have to have a svg file to import. The
#following lines of code will create a svg in a temporary files:

svg.file.directory <- tempfile(fileext = ".svg") # Creates temporary file
writeLines(example.ammonite.svg, svg.file.directory) # Writes svg in the file

print(paste("An example .svg file was created at ", svg.file.directory,
            sep = ""))

# The pointsvg function allows to import simple svg drawings into R

ammonite.drawing <- pointsvg(file = svg.file.directory) # Provide file

plot(c(-2,2), c(-2,2), type = "n")

placesvg(ammonite.drawing)

# If you want to import your own .svg file uncomment the following line:

# pointsvg(file.choose())

StratigrapheR documentation built on May 29, 2021, 1:05 a.m.