Skip to contents

parse wkt into smaller bits

Usage

wkt_parse(wkt, geom_big, geom_size = 40, geom_n = 10)

Arguments

wkt

(character) A WKT string. Required.

geom_big

(character) One of "axe" or "bbox". Required.

geom_size

(integer) An integer indicating size of the cell. Default: 40.

geom_n

(integer) An integer indicating number of cells in each dimension. Default: 10.

Examples

wkt <- [2576 chars quoted with '"']
wkt <- gsub("\n", " ", wkt)

if (requireNamespace("sf", quietly=TRUE)) {
# to a bounding box in wkt format
wkt_parse(wkt, geom_big = "bbox")

# to many wkt strings, chopped up from input
wkt_parse(wkt, geom_big = "axe")
wkt_parse(wkt, geom_big = "axe", 60)
wkt_parse(wkt, geom_big = "axe", 30)
wkt_parse(wkt, geom_big = "axe", 20)
wkt_parse(wkt, geom_big = "axe", 10)
wkt_parse(wkt, geom_big = "axe", 5)
}
#>  [1] "POLYGON ((-12.40057 35.10684, -14.06504 36.58364, -11.03829 36.58364, -12.40057 35.10684))"                                                                                                                        
#>  [2] "POLYGON ((-5.774904 36.58364, -5.740409 36.58364, -5.740409 36.44801, -5.774904 36.58364))"                                                                                                                        
#>  [3] "POLYGON ((-5.545097 35.68001, -5.740409 36.44801, -5.740409 36.58364, -0.7404095 36.58364, -0.7404095 32.65386, -5.545097 35.68001))"                                                                              
#>  [4] "POLYGON ((0.9588093 31.58364, -0.7404095 32.65386, -0.7404095 36.58364, 4.259591 36.58364, 4.259591 34.78782, 0.9588093 31.58364))"                                                                                
#>  [5] "POLYGON ((6.056466 36.53211, 4.259591 34.78782, 4.259591 36.58364, 6.083733 36.58364, 6.056466 36.53211))"                                                                                                         
#>  [6] "POLYGON ((18.71272 36.10722, 18.68536 36.58364, 19.25959 36.58364, 19.25959 36.22296, 18.71272 36.10722))"                                                                                                         
#>  [7] "POLYGON ((22.36042 36.58364, 24.25959 36.58364, 24.25959 35.16204, 22.36042 36.58364))"                                                                                                                            
#>  [8] "POLYGON ((19.25959 36.22296, 19.25959 36.58364, 20.96375 36.58364, 19.25959 36.22296))"                                                                                                                            
#>  [9] "POLYGON ((26.27131 33.6562, 24.25959 35.16204, 24.25959 36.58364, 29.25959 36.58364, 29.25959 35.31984, 26.27131 33.6562))"                                                                                        
#> [10] "POLYGON ((29.25959 35.31984, 29.25959 36.58364, 31.52968 36.58364, 29.25959 35.31984))"                                                                                                                            
#> [11] "POLYGON ((-11.03829 36.58364, -14.06504 36.58364, -15.74041 38.07011, -14.68572 41.31532, -14.34205 41.58364, -10.74041 41.58364, -10.74041 36.90657, -11.03829 36.58364))"                                        
#> [12] "POLYGON ((-6.775566 40.51835, -9.412284 38.34636, -10.74041 36.90657, -10.74041 41.58364, -5.740409 41.58364, -5.740409 36.58364, -5.774904 36.58364, -6.775566 40.51835))"                                        
#> [13] "POLYGON ((-1.326347 39.30494, -0.7404095 39.66198, -0.7404095 36.58364, -5.740409 36.58364, -5.740409 41.58364, -1.491522 41.58364, -1.326347 39.30494))"                                                          
#> [14] "POLYGON ((2.189278 41.44722, 2.360722 41.58364, 4.259591 41.58364, 4.259591 36.58364, -0.7404095 36.58364, -0.7404095 39.66198, 2.189278 41.44722))"                                                               
#> [15] "POLYGON ((8.165841 40.51835, 6.083733 36.58364, 4.259591 36.58364, 4.259591 41.58364, 8.577777 41.58364, 8.165841 40.51835))"                                                                                      
#> [16] "POLYGON ((12.56037 41.05074, 12.56037 41.58364, 14.25959 41.58364, 14.25959 41.39107, 12.56037 41.05074))"                                                                                                         
#> [17] "POLYGON ((18.53693 39.16879, 15.37287 38.34636, 15.19709 41.57884, 14.25959 41.39107, 14.25959 41.58364, 19.25959 41.58364, 19.25959 36.58364, 18.68536 36.58364, 18.53693 39.16879))"                             
#> [18] "POLYGON ((22.93147 40.65185, 24.25959 40.3143, 24.25959 36.58364, 22.36042 36.58364, 22.05256 36.81408, 20.96375 36.58364, 19.25959 36.58364, 19.25959 41.58364, 21.39992 41.58364, 22.93147 40.65185))"           
#> [19] "POLYGON ((25.56818 39.98171, 29.25959 40.71522, 29.25959 36.58364, 24.25959 36.58364, 24.25959 40.3143, 25.56818 39.98171))"                                                                                       
#> [20] "POLYGON ((29.61115 40.78508, 32.951 40.38459, 32.951 37.37492, 31.52968 36.58364, 29.25959 36.58364, 29.25959 40.71522, 29.61115 40.78508))"                                                                       
#> [21] "POLYGON ((-11.69744 43.64836, -10.74041 43.38703, -10.74041 41.58364, -14.34205 41.58364, -11.69744 43.64836))"                                                                                                    
#> [22] "POLYGON ((-8.884941 42.88036, -5.740409 43.32116, -5.740409 41.58364, -10.74041 41.58364, -10.74041 43.38703, -8.884941 42.88036))"                                                                                
#> [23] "POLYGON ((-7.658767 46.58364, -5.740409 46.58364, -5.740409 44.82678, -7.658767 46.58364))"                                                                                                                        
#> [24] "POLYGON ((-4.314628 43.52103, -5.740409 44.82678, -5.740409 46.58364, -2.956877 46.58364, -2.732597 46.25999, -1.677909 44.15498, -1.491522 41.58364, -5.740409 41.58364, -5.740409 43.32116, -4.314628 43.52103))"
#> [25] "POLYGON ((4.259591 43.09461, 4.259591 41.58364, 2.360722 41.58364, 4.259591 43.09461))"                                                                                                                            
#> [26] "POLYGON ((2.294606 46.58364, 4.259591 46.58364, 4.259591 43.5926, 2.294606 46.58364))"                                                                                                                             
#> [27] "POLYGON ((8.577777 41.58364, 4.259591 41.58364, 4.259591 43.09461, 4.474434 43.26557, 4.259591 43.5926, 4.259591 46.58364, 9.259591 46.58364, 9.259591 43.34684, 8.577777 41.58364))"                              
#> [28] "POLYGON ((12.56037 44.02873, 14.25959 44.9936, 14.25959 41.58364, 12.56037 41.58364, 12.56037 44.02873))"                                                                                                          
#> [29] "POLYGON ((9.572091 44.15498, 9.259591 43.34684, 9.259591 46.58364, 10.27153 46.58364, 9.572091 44.15498))"                                                                                                         
#> [30] "POLYGON ((15.19709 45.52594, 15.71216 46.58364, 19.25959 46.58364, 19.25959 41.58364, 14.25959 41.58364, 14.25959 44.9936, 15.19709 45.52594))"                                                                    
#> [31] "POLYGON ((23.10725 43.77542, 24.25959 46.50311, 24.25959 43.48465, 23.10725 43.77542))"                                                                                                                            
#> [32] "POLYGON ((19.59162 44.90682, 20.11897 42.36297, 21.39992 41.58364, 19.25959 41.58364, 19.25959 46.58364, 19.48138 46.58364, 19.59162 44.90682))"                                                                   
#> [33] "POLYGON ((29.25959 45.61967, 29.25959 44.14852, 27.67756 42.6222, 24.25959 43.48465, 24.25959 46.50311, 24.29361 46.58364, 28.73138 46.58364, 29.25959 45.61967))"                                                 
#> [34] "POLYGON ((34.00568 45.2791, 33.73251 46.58364, 34.25959 46.58364, 34.25959 45.31993, 34.00568 45.2791))"                                                                                                           
#> [35] "POLYGON ((29.78693 44.65729, 29.25959 44.14852, 29.25959 45.61967, 29.78693 44.65729))"                                                                                                                            
#> [36] "POLYGON ((-8.357597 47.22364, -8.181816 50.12442, -5.740409 49.68707, -5.740409 46.58364, -7.658767 46.58364, -8.357597 47.22364))"                                                                                
#> [37] "POLYGON ((-5.017753 49.55761, -2.956877 46.58364, -5.740409 46.58364, -5.740409 49.68707, -5.017753 49.55761))"                                                                                                    
#> [38] "POLYGON ((2.189278 46.74397, 1.837716 50.34928, 4.259591 50.02727, 4.259591 46.58364, 2.294606 46.58364, 2.189278 46.74397))"                                                                                      
#> [39] "POLYGON ((6.935372 49.67151, 5.542306 51.58364, 9.259591 51.58364, 9.259591 46.58364, 4.259591 46.58364, 4.259591 50.02727, 6.935372 49.67151))"                                                                   
#> [40] "POLYGON ((10.62678 47.81718, 10.27153 46.58364, 9.259591 46.58364, 9.259591 51.58364, 14.25959 51.58364, 14.25959 48.37437, 10.62678 47.81718))"                                                                   
#> [41] "POLYGON ((16.42756 48.05272, 17.48225 48.86866, 14.25959 48.37437, 14.25959 51.58364, 19.25959 51.58364, 19.25959 46.58364, 15.71216 46.58364, 16.42756 48.05272))"                                                
#> [42] "POLYGON ((23.63459 49.44345, 19.41584 47.58057, 19.48138 46.58364, 19.25959 46.58364, 19.25959 51.58364, 23.92866 51.58364, 23.63459 49.44345))"                                                                   
#> [43] "POLYGON ((28.38068 47.22364, 28.73138 46.58364, 24.29361 46.58364, 24.5135 47.10412, 26.79865 49.55761, 24.46761 51.58364, 29.25959 51.58364, 29.25959 48.50439, 28.38068 47.22364))"                              
#> [44] "POLYGON ((33.30256 48.63687, 30.1385 49.78513, 29.25959 48.50439, 29.25959 51.58364, 34.25959 51.58364, 34.25959 46.58364, 33.73251 46.58364, 33.30256 48.63687))"                                                 
#> [45] "POLYGON ((5.001778 52.32557, 7.814278 51.67627, 7.814278 54.52456, 9.259591 53.32283, 9.259591 51.58364, 5.542306 51.58364, 5.001778 52.32557))"                                                                   
#> [46] "POLYGON ((14.25959 52.84759, 14.25959 51.58364, 9.259591 51.58364, 9.259591 53.32283, 10.97834 51.89375, 10.97834 55.43241, 13.2635 52.53992, 14.25959 52.84759))"                                                 
#> [47] "POLYGON ((18.36115 54.11446, 19.25959 54.03517, 19.25959 51.58364, 14.25959 51.58364, 14.25959 52.84759, 18.36115 54.11446))"                                                                                      
#> [48] "POLYGON ((21.87678 53.80419, 24.25959 54.15424, 24.25959 51.76444, 23.98615 52.0021, 23.92866 51.58364, 19.25959 51.58364, 19.25959 54.03517, 21.87678 53.80419))"                                                 
#> [49] "POLYGON ((24.68928 54.21736, 28.2049 54.32002, 29.25959 53.64592, 29.25959 51.58364, 24.46761 51.58364, 24.25959 51.76444, 24.25959 54.15424, 24.68928 54.21736))"                                                 
#> [50] "POLYGON ((30.49006 52.85948, 34.25959 52.76454, 34.25959 51.58364, 29.25959 51.58364, 29.25959 53.64592, 30.49006 52.85948))"