raster2vector: Converts raster image matrix into list of polygons.

Description Usage Arguments Value Examples

Description

Takes a raster matrix and vectorize it by polygons. Typically the nature of artefact images is linear and can be vectorized in much more efficient way than draw a series of 90 degrees lines.

Usage

1
2
raster2vector(raster, from = 0, to = 1, step = 0.1, precision = 1L,
  exclave = TRUE)

Arguments

raster

input matrix of numeric values.

from

lower (greater than) margin for recognizable polygon values.

to

upper (less than or equal) margin.

step

values gradient.

precision

linearization precision in matrix cells.

exclave

polygons may have other inside.

Value

list of integer matrixes that represent polygon coordinates in two columns.

Examples

1
2
3
library(datasets)
raster2vector(volcano, 100, 200, 60, 1, FALSE)
raster2vector(volcano, 120, 200, 20)

Example output

[[1]]
      [,1] [,2]
 [1,]   19    1
 [2,]    2    1
 [3,]    1    7
 [4,]    2   11
 [5,]    1   61
 [6,]   62   61
 [7,]   67   56
 [8,]   66   55
 [9,]   66   53
[10,]   65   51
[11,]   67   49
[12,]   69   45
[13,]   71   45
[14,]   77   39
[15,]   80   38
[16,]   80   36
[17,]   82   36
[18,]   81   34
[19,]   84   34
[20,]   86   32
[21,]   87   23
[22,]   85   23
[23,]   81   21
[24,]   84   15
[25,]   83   11
[26,]   85    9
[27,]   79    2
[28,]   31    3
[29,]   38    9
[30,]   42   10
[31,]   53    6
[32,]   54    7
[33,]   64    8
[34,]   66    6
[35,]   71    5
[36,]   71    7
[37,]   75   15
[38,]   74   20
[39,]   75   22
[40,]   76   27
[41,]   75   28
[42,]   63   47
[43,]   58   47
[44,]   55   46
[45,]   34   57
[46,]   22   58
[47,]   22   56
[48,]   11   52
[49,]   10   51
[50,]   10   49
[51,]    4   42
[52,]    2   36
[53,]    7   20
[54,]   13   10
[55,]   14    9
[56,]   17    1

[[2]]
      [,1] [,2]
 [1,]   26   26
 [2,]   25   21
 [3,]   23   21
 [4,]   18   23
 [5,]   15   36
 [6,]   22   45
 [7,]   24   45
 [8,]   23   44
 [9,]   23   41
[10,]   22   29
[11,]   24   26

[[3]]
     [,1] [,2]
[1,]   28   45

[[4]]
      [,1] [,2]
 [1,]   74   14
 [2,]   70    6
 [3,]   67    6
 [4,]   65    8
 [5,]   53    9
 [6,]   51    7
 [7,]   43   10
 [8,]   37   11
 [9,]   26    2
[10,]   20    1
[11,]   18    2
[12,]   14   12
[13,]   12   14
[14,]    5   31
[15,]   15   31
[16,]   17   22
[17,]   26   20
[18,]   27   21
[19,]   27   27
[20,]   25   27
[21,]   24   30
[22,]   23   40
[23,]   24   43
[24,]   29   44
[25,]   28   47
[26,]   25   45
[27,]   21   46
[28,]   18   43
[29,]   18   41
[30,]   15   37
[31,]   14   32
[32,]    4   32
[33,]    3   38
[34,]    9   47
[35,]   12   51
[36,]   23   55
[37,]   23   57
[38,]   33   57
[39,]   54   46
[40,]   59   45
[41,]   62   46
[42,]   65   43
[43,]   72   30
[44,]   75   23
[45,]   74   21

[[1]]
      [,1] [,2]
 [1,]   26   26
 [2,]   25   21
 [3,]   23   21
 [4,]   18   23
 [5,]   15   36
 [6,]   22   45
 [7,]   24   45
 [8,]   23   44
 [9,]   23   41
[10,]   22   29
[11,]   24   26

[[2]]
     [,1] [,2]
[1,]   28   45

[[3]]
     [,1] [,2]
[1,]   33   36
[2,]   32   31
[3,]   29   30
[4,]   27   31
[5,]   26   35
[6,]   28   38
[7,]   31   38

[[4]]
      [,1] [,2]
 [1,]   52   27
 [2,]   52   24
 [3,]   51   21
 [4,]   49   21
 [5,]   47   22
 [6,]   41   23
 [7,]   30   19
 [8,]   28   17
 [9,]   23   15
[10,]   20   18
[11,]   14   20
[12,]   11   36
[13,]   14   42
[14,]   16   42
[15,]   16   44
[16,]   19   47
[17,]   30   51
[18,]   36   46
[19,]   36   39
[20,]   38   39
[21,]   40   37
[22,]   43   31
[23,]   45   31
[24,]   47   30
[25,]   49   32
[26,]   51   30

[[5]]
      [,1] [,2]
 [1,]   70   21
 [2,]   68   15
 [3,]   58   14
 [4,]   55   15
 [5,]   39   17
 [6,]   25    8
 [7,]   23   10
 [8,]   20   15
 [9,]   14   17
[10,]   12   19
[11,]    8   32
[12,]    7   35
[13,]   10   43
[14,]   15   46
[15,]   15   48
[16,]   18   51
[17,]   31   54
[18,]   39   48
[19,]   41   41
[20,]   43   41
[21,]   44   38
[22,]   53   40
[23,]   57   36
[24,]   59   30
[25,]   61   30
[26,]   66   28

[[6]]
      [,1] [,2]
 [1,]   74   14
 [2,]   70    6
 [3,]   67    6
 [4,]   65    8
 [5,]   53    9
 [6,]   51    7
 [7,]   43   10
 [8,]   37   11
 [9,]   26    2
[10,]   20    1
[11,]   18    2
[12,]   14   12
[13,]   12   14
[14,]    6   27
[15,]    3   38
[16,]    9   47
[17,]   12   51
[18,]   23   55
[19,]   23   57
[20,]   33   57
[21,]   54   46
[22,]   59   45
[23,]   62   46
[24,]   65   43
[25,]   72   30
[26,]   75   23
[27,]   74   21

fasteraster documentation built on May 2, 2019, 3:35 p.m.