Closed damianooldoni closed 8 months ago
Probably something for another issue, still found while running the script prepare_dataset.R
on this branch.
One receiver, s-9a
, is not projected on the line: see screenshot below.
This results in Inf
values while calculating distances of course. Something strange occurring in gidstance::dist2Line
function in find.projections.receivers()
, I am afraid. I will 🔍 further
Ok, I think I got it. I am now using terra::nearest()
function instead of geosphere::dist2Lines()
to find the projection of the receivers. This has multiple benefits:
terra::nearest()
works in x-y Euclidean spaceNotice that the original projection is not needed anymore and so the argument projection
has been removed. The modified find.projections.receivers()
requires a planar CRS, which is actually always the case in this analysis. If not, a conversion is needed before using the function.
Screenshot about the wrong, now correct, projection of the receivers:
Issue solved 👏 !
This PR should fix #79. The error was due to a mix of polygons (row 1) and multipolygons (row2) in
ws_bpns
area. Extracting coordinates of mixed elements (called collections) is not allowed as they have different (number of) columns. But we were interested only in first two columns (the X and Y columns) so the solution is to extract coordinates for each row and then binding the rows together viarbind
as actually we already did for binding the coordinates of two study areas.I could run the code in
prepare_dataset.R
:Let me know if you also can and if results make sense 🔍