Pakillo / Pakillo/rSDM

help request for points2nearest cell

Open
#3 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
7
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Hi Pakillo,

I'm using this (super-useful-thank you!) function for some SDM work but have run into an issue/potential improvement that I am hoping you may be able to help me sort out.

I have a spatialpoints object with N points. Each of these points/locations needs to reference a different layer in a raster stack or brick (the different layers are rasters of the same variable but at different times (i.e.,months), and they have NAs in different places- due to, for example, changes in cloud cover). So moving points to the nearest non-NA cell, must be layer-specific. However, it appears that the "layer" argument takes only a single layer as input.

I'm wondering if you could adapt/modify the function to permit it to take a vector (with a length equal to the number of points in "locs") for the "layer" argument, so that each location (each point in the spatialpoints object) is moved based on a distinct raster layer in the brick/stack (specified by layer name)?

In other words, imagine my spatialpoints object (locs) has n=100 coordinates. These points correspond to different days of the year. Then I also have a raster stack with, say, 365 layers, one for each day of the year. Imagine these layers are names as character strings ("day1","day2"......).

I'd like to be able to run points2nearestcell on the 100 points, but instead of specifying a single raster layer, I'd provide "layer" with a vector of 100 layer names, and the function would relocate each point based on it's corresponding layer name in the vector?

This would be really helpful when dealing with any form of time-varying data where NA values do not always fall in the same locations over time.

Thanks in advance for your time!!
C

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the points2nearestcell function and inspect how its layer argument selects a raster layer for SpatialPoints locations. Verify the expected behavior for a layer vector matching the number of points, including named layers and differing NA cells; done means each point is relocated using its corresponding layer.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.