On Thu, 11 Jul 2013, Barry Rowlingson wrote:

On Thu, Jul 11, 2013 at 1:27 PM, Tscheikner-Gratl, Franz
<franz.tscheikner-gr...@uibk.ac.at> wrote:
Thanks for your reply.
 The problem is that I have data of a pipe network with missing attributes 
(construction year). So I would like to see what are the constructions years of 
the intersecting (neighbouring) pipes.
Then I would fill the missing attributes with the oldest construction age.
I could make it by hand with ArcGis but it would be lots of work - so I thought 
I could make it with R.

That's a bit clearer - if you could make a simple example shapefile
that shows the problem (you don't have to share all your data) I'm
pretty sure its just a case of selecting the pipe features and looping
over one of the intersection functions, which should return the  The
problem is if you have more than one labelled pipe crossing an
unlabelled pipe, or if no pipes cross - or in that case do you want
the nearest pipe? Maybe nearest is a better solution in any case
(since crossing pipes have distance zero)...

Maybe gTouches() rather than gIntersects() as maybe the contiguous pipe segments to segments with NA attribute values can by listed, while I'm not sure whether they intersect:

library(rgeos)
l1 = readWKT("LINESTRING(0 0,2 2)")
l2 = readWKT("LINESTRING(1 1,2 0)")
gTouches(l1,l2)
gIntersects(l1,l2)

so they do touch and intersect. I would suggest identifying the NA attribute Lines objects first, then loop over them to find their contiguous neighbours. If there are two neighbbours, and the value of interest is identical, it may be copied across, if different, or for three or more with different values, manual intervention may be needed, unless there is some other non-NA variable indicating which bit of the jigsaw puzzle belongs where.

Roger


Worst case scenario is a double loop over features with missing data
over features with data...

Barry

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to