= Distance source = back to first page .. {{{ alter table ccm21.riversegments add column distance_source numeric; }}} The distance source is calculated by the following request : The distance sea corresponds to the distance of the downstream node of each riversegment The distance source for a riversegments A is the maximum of the distance + length of the upstream riversegment Note the upstream catchment function does not return the catchment upstream... so we have to use the upstream_segment function [[Image(source:data/Docs/trac/upstream_segments_and_catchment.jpg,300)]] In the ccm we find the cum_length which is the cumulated length of upstream riversegments but not the distance to the farthest source {{{ select round(max(cum_len_sea+shape_leng) -(select cum_len_sea from ccm21.riversegments where gid =234706)) as dist_source from ccm21.riversegments where gid in (select ccm21.upstream_segments(234706)); }}}