Open roth-mh opened 4 years ago
I am seeing the same behaviour, where I expect PA
to emerge unscathed from the triangulation it ends up 'row-wise' in the output not 'column-wise':
tri <- pslg(P = tpts, PA = tattrs) %>%
triangulate()
> head(tattrs)
x y
1 -428675.9 1520344
2 -1197290.8 7794188
3 -1120150.7 7234575
4 -1048583.9 6613223
5 -973499.6 5945572
6 -892969.4 5242144
> head(tri$PA)
[,1] [,2]
[1,] -428675.9 -1197290.8
[2,] -1120150.7 -1048583.9
[3,] -973499.6 -892969.4
[4,] -807038.3 -716485.6
[5,] -622414.4 -526061.0
[6,] -1524302.5 -1417125.3
For what it's worth, I can untangle the attributes matrix with this function, but obviously would be a lot better to fix it at source!
untangle <- function(triPA) {
return ( matrix( c( t( triPA ) ), ncol = dim(triPA)[2] ) );
}
or with pipes
untangle <- function(triPA) {
nc <- dim(triPA)[2]
return (triPA %>%
t() %>% # transpose
c() %>% # vectorise
matrix(ncol = nc)) # column-wise repopulate the original shape
}
Sorry for the delay in looking at this. It would indeed be desirable to fix the issue. I have been very busy, but I hope to have some time next week (during my holiday) to look at it properly.
This isn't more important than your holiday (at least not for me)! I assume the issue is some kind of index inversion when you are populating the output PA matrix
when I am triangulating a pslg object with attributes, the triangulate function seems to (kind of) transpose the attribute matrix. in the example below i would expect PA to stay the same from the pslg object to the DT object. Am I misunderstanding the intended functionality?