Extract topological information from netgeom column
ssn_get_netgeom(x, netvars = "all", reformat = FALSE)
An sf data.frame found in an SSN
object or the
netgeom column as a vector
Network coordinate variables to return. Default is "all". For edges, valid column names include: "NetworkID", "SegmentID", and "DistanceUpstream". For point datasets, valid column names include "NetworkID", "SegmentID", "DistanceUpstream", "ratio", "pid", and "locID".
Convert network coordinate variables from character to numeric.
If more than one column is requested using netvars, the function returns a data.frame (default). If only one column is requested, the result is a vector.
When an SSN
object is generated using the
importSSN
function, a text column named "netgeom" is added
to the edges, observed sites, and prediction sites (if they
exist) data.frames. The netgeom column contains data used to
describe how edge and site features relate to one another in
topological space. For edges, netgeom values contain the
"ENETWORK" prefix, with 3 space delimited values in parentheses:
"ENETWORK (NetworkID SegmentID DistanceUpstream)". For point
datasets (observed and prediction sites), the values contain the
"SNETWORK" prefix, followed by 6 space delimited values in parentheses:
"SNETWORK (NetworkID SegmentID DistanceUpstream ratio pid locID)". The
ssn_get_netgeom
function extracts and converts these
values from text to numeric, returning either a data.frame
(default) or vector containing the variables requested via
netvars
.
# Copy the mf04p .ssn data to a local directory and read it into R
# When modeling with your .ssn object, you will load it using the relevant
# path to the .ssn data on your machine
copy_lsn_to_temp()
temp_path <- paste0(tempdir(), "/MiddleFork04.ssn")
mf04p <- ssn_import(temp_path, overwrite = TRUE)
ssn_get_netgeom(mf04p$obs)
#> NetworkID SegmentID DistanceUpstream ratio pid locID
#> 1 1 1 14295.196345228 0.0143033570193725 1 1
#> 2 1 1 16258.1867133034 0.626023498621516 2 2
#> 3 1 1 16794.9565779269 0.793295301344197 3 3
#> 4 1 5 909.937835040871 0.231819253798763 4 4
#> 5 1 5 1692.25764134473 0.515501826191856 5 5
#> 6 1 10 8046.69959654784 0.28093206947971 6 6
#> 7 1 13 10443.8838684547 0.613552417711556 7 7
#> 8 1 15 13865.3815621499 0.907439930466464 8 8
#> 9 1 17 14323.7279440717 0.182376231507493 9 9
#> 10 1 17 14580.7850080222 0.812239349337638 10 10
#> 11 1 19 15652.4273971773 0.549770203960467 11 11
#> 12 1 21 18642.8232807059 0.157200895942302 12 12
#> 13 1 21 19566.2045370585 0.639335640749524 13 13
#> 14 2 33 3194.82758834595 0.321185040919459 14 14
#> 15 2 34 3896.10674038296 0.0690361937952187 15 15
#> 16 2 34 4857.50889815636 0.370693074274211 16 16
#> 17 2 34 5886.68489225268 0.693615191031243 17 17
#> 18 2 34 6281.22686215765 0.817409691487961 18 18
#> 19 2 36 7300.18896771736 0.472020290982274 19 19
#> 20 2 37 8386.87883528115 0.467609736277533 20 20
#> 21 2 37 8626.98482357545 0.595431065021748 21 21
#> 22 2 39 10019.9727397032 0.481795562544374 22 22
#> 23 2 42 4049.94559903902 0.241892607277062 23 23
#> 24 2 48 8914.2984583901 0.356571475118011 24 24
#> 25 2 49 9295.32664671222 0.223896901080731 25 25
#> 26 2 49 9711.54632884272 0.751115282023418 26 26
#> 27 2 52 12658.4900937506 0.170490508605362 27 27
#> 28 2 52 14103.2031153509 0.799102017170274 28 28
#> 29 2 53 16019.2025746132 0.601882501113124 29 29
#> 30 2 55 18447.5789987791 0.132889204229652 30 30
#> 31 2 58 3405.72135312965 0.609185232315584 31 31
#> 32 2 58 4046.04417334624 0.973908806043524 32 32
#> 33 2 60 5365.42224130655 0.845110196771577 33 33
#> 34 2 61 6489.59759943874 0.885802548015722 34 34
#> 35 2 61 5794.51481160791 0.258397975972908 35 35
#> 36 2 63 7547.78605502196 0.128723349502858 36 36
#> 37 2 64 10022.9334714274 0.703550475006261 37 37
#> 38 2 66 10879.7081769225 0.078434677103365 38 38
#> 39 2 67 11985.9719106275 0.0893958570488306 39 39
#> 40 2 67 12357.0088970759 0.242744463683594 40 40
#> 41 2 68 15080.7113188755 0.665890884639618 41 41
#> 42 2 69 15672.8306470736 0.0751878474972271 42 42
#> 43 2 71 9921.48731634449 0.881800162965071 43 43
#> 44 2 95 10871.508857035 0.196749884784435 44 44
#> 45 2 110 11795.0008892232 0.0160819902932108 45 45
ssn_get_netgeom(mf04p$edges, "DistanceUpstream")
#> DistanceUpstream
#> 1 17458.2653443092
#> 2 18357.2013473613
#> 3 20793.1520843239
#> 4 270.643033814759
#> 5 3028.37256123817
#> 6 4402.46334120276
#> 7 5256.11048818444
#> 8 6616.51936213131
#> 9 7886.30445015111
#> 10 8457.24370494599
#> 11 9024.57776816167
#> 12 9536.5135324752
#> 13 11015.3934289375
#> 14 12325.9762679366
#> 15 14022.4029321479
#> 16 14249.2973300564
#> 17 14657.4130883438
#> 18 14790.6182826554
#> 19 16358.198897817
#> 20 18341.7531704135
#> 21 20256.9465189487
#> 22 8056.91207732279
#> 23 9607.96481229633
#> 24 13105.9441561817
#> 25 14112.2130888775
#> 26 16613.992659694
#> 27 5611.09385125239
#> 28 7959.14006422809
#> 29 1556.81337220539
#> 30 1920.27673834595
#> 31 2336.21218484763
#> 32 2967.11873356165
#> 33 3676.08342921632
#> 34 6863.15529791302
#> 35 7113.95880148187
#> 36 7508.49727746126
#> 37 9386.94738162795
#> 38 9805.94712673543
#> 39 10250.1720835564
#> 40 10289.8733396204
#> 41 13963.1651296954
#> 42 5221.65430891865
#> 43 5793.50030354748
#> 44 6280.45578933733
#> 45 7277.66171418537
#> 46 7449.52533785191
#> 47 8801.0974364933
#> 48 9118.56820966533
#> 49 9908.03173592987
#> 50 11074.7483484508
#> 51 12266.6584863342
#> 52 14564.9190207277
#> 53 16981.1440334103
#> 54 17918.0916672167
#> 55 21902.5186538316
#> 56 25336.5841329242
#> 57 26164.3010725867
#> 58 4091.85088314091
#> 59 4586.16095740494
#> 60 5508.24341112338
#> 61 6616.11354596741
#> 62 7197.21170561536
#> 63 9920.68301645799
#> 64 10066.0179406772
#> 65 10803.9630452421
#> 66 11769.6727858538
#> 67 14189.2382099604
#> 68 15528.0057610398
#> 69 17454.1798816533
#> 70 20006.2582618593
#> 71 10029.1136375311
#> 72 10892.8779616433
#> 73 11270.8487206139
#> 74 11844.159173113
#> 75 13763.1476372381
#> 76 12715.7735594781
#> 77 14546.8345236079
#> 78 17838.6435897391
#> 79 8887.67517891411
#> 80 8891.97355540552
#> 81 12839.2250328338
#> 82 5433.90934000716
#> 83 6124.9118981488
#> 84 6267.87682697666
#> 85 6677.35714098017
#> 86 8073.26914055922
#> 87 11585.4944923386
#> 88 12057.2455602907
#> 89 13058.8169909537
#> 90 19026.6198060218
#> 91 18924.7499077214
#> 92 19525.005382963
#> 93 19880.9175088897
#> 94 21486.7688274084
#> 95 13246.0911694392
#> 96 14399.5534168745
#> 97 10396.7058430995
#> 98 12938.8411905711
#> 99 17726.9196395517
#> 100 15870.5572203595
#> 101 20989.1229380097
#> 102 15125.2684792853
#> 103 15389.8725132931
#> 104 14793.2194915557
#> 105 14808.0000676813
#> 106 18347.8931324167
#> 107 19583.0855759017
#> 108 14729.3812837901
#> 109 6772.63827190942
#> 110 13344.6086555785
#> 111 12092.1446817101
#> 112 9641.34969827759
#> 113 7320.38318896619
#> 114 12444.8239211523
#> 115 8982.07724984958
#> 116 10769.239683546
#> 117 8257.2511028149
#> 118 14762.1705229917
#> 119 24929.5055970415
#> 120 13100.4871772562
#> 121 19498.8928168494
#> 122 7406.49129825225
#> 123 17122.0987313141
#> 124 6939.68851956591
#> 125 7564.94695586144
#> 126 10026.1216247482
#> 127 7873.39351216316
#> 128 13530.4857971852
#> 129 20684.2844080521
#> 130 3786.82459872068
#> 131 4527.88648086542
#> 132 18932.7126207706
#> 133 8241.47433250851
#> 134 9033.46264256387
#> 135 5684.90317017307
#> 136 9288.41653485173
#> 137 14064.8357297009
#> 138 13639.3482775505
#> 139 9878.97609862289
#> 140 6900.36121898015
#> 141 6948.21909422703
#> 142 9589.88284428016
#> 143 14957.8325228195
#> 144 8207.03249122928
#> 145 12218.7636229605
#> 146 14966.1256740333
#> 147 10353.691753873
#> 148 10436.3448078734
#> 149 16900.7317617924
#> 150 11569.327853944
#> 151 13332.8551098625
#> 152 11680.4722375554
#> 153 12568.0861312944
#> 154 13081.1159536959
#> 155 12724.5995838964
#> 156 17091.6681515776
#> 157 15598.4603054857
#> 158 14400.3070941811
#> 159 15886.9084558951
#> 160 10139.4205086529
#> 161 7406.60614162612
#> 162 6346.02608978609
#> 163 7466.07885573737