Closed dill closed 3 years ago
Looks like the whole polygon is duplicated? I have a non functioning laptop at the moment. Can you plot the x and y coordinates a sfunctions of index, so one can see if the loops go the same direction or if the duplicate is in the opposite direction? I’m not sure where the poly data originated.
Well I think they might have come from me originally... but I don't know how they went from the 45 vertex versions to these... Perhaps something strange happened during projection? (Version in dsm
is in lat/long.)
As requested:
par(mfrow=c(1,2))
plot(poly[,1], ylab="x")
plot(poly[,2], ylab="y")
It appears that the code that converted the data from dsm is here: https://github.com/cran/inlabru/blob/master/R/data.mexdolphin.R Unfortunately it can’t be run anymore due to a removed function, but the code might reveal the source of the problem. In any case, it’s clear that the polygon info is wrong!
This is the culprit:
polyloc = as.data.frame(mexdolphin$mesh$loc[mexdolphin$mesh$segm$int$idx,c(1,2)])
It assumed incorrectly that segm$int$idx would be a vector, but it’s normally a two-column matrix.
The increase from 45 to 79 was due to the dsm polygon being used as input to the mesh refinement, and then extracted from the resulting mesh.
Aha! Okay, I was going to volunteer to fix this but given that the function is missing I'll shy away from that task...
On 20/11/2018 15:52, Finn Lindgren wrote:
This is the culprit: |polyloc = as.data.frame(mexdolphin$mesh$loc[mexdolphin$mesh$segm$int$idx,c(1,2)])| It assumed incorrectly that segm$int$idx would be a vector, but it’s normally a two-column matrix. The increase from 45 to 79 was due to the dsm polygon being used as input to the mesh refinement, and then extracted from the resulting mesh.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fbachl/inlabru/issues/53#issuecomment-440322846, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAHodcSkj7vons-PLB_g0LXppwau4-mks5uxCVGgaJpZM4YrQyZ.
The polygon in
mexdolphin$ppoly
seems wrong to me.In
dsm
the polygon has 45 vertices. Ininlabru
it has 158. This in itself is of course not really an issue, but the polygon vertices seem to loop back on themselves. Perhaps it's easier to show this in graphics/code:Okay, fine, then we can append the first vertex as the last and make a polygon, but what about the other 79 points?
We get almost but not quite the same thing again. Plotting everyting and zooming-in, we see there is a weird overlap:
Apologies if there is some INLA-y reason that you do this (if there is I'm keen to know!), it's caused havoc for me doing point-in-polygon using
mgcv::inSide
this afternoon.