Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location points moving #22

Open
nhelm opened this issue Dec 6, 2018 · 4 comments
Open

Location points moving #22

nhelm opened this issue Dec 6, 2018 · 4 comments

Comments

@nhelm
Copy link

nhelm commented Dec 6, 2018

Hello,

I am having a few issues attempting to thin species records. I am working with a species that has a relatively small range and would like to be able to thin records in a projection that preserves distance (in this case a UTM zone, the range falls only within one zone). My first question would be is it possible to use coordinates other than lat long (UTM in this case) while thinning? The algorithm runs but returns a locations not thinned correctly.

Because that wasn't working I projected my data to WGS84 with lat long coordinates. The data were thinned correctly, however, when I compared the remaining location points with my WGS84 projected data, the points that were preserved after thinning were anywhere from 9 to 15m away from any original location point. I am not sure why they would shift during the thinning process, any suggestions?

Thanks!

@mlammens
Copy link
Owner

Hi @nhelm . Sorry for the delayed response. At the moment, there isn't a way to thin with spThin in anything other than decimal degree lat/lon values. This is because the distance calculation function fields::rdist.earth requires these kinds of values. This function should return pair-wise distances that preserve geographic distance.

As for the second question, do you mean that there was some sort of error produced with switching to and from WGS84? I'm not too sure why that would happen to be honest.

There is a possible work around. You could thin in WGS84, but rather than use the new lat/lon points, use the row.names from the thinned data set to index the original data set that's in UTM. If you want more info on that, drop me a line.

@tinsman
Copy link

tinsman commented Aug 7, 2021

Hi @mlammens I'd like to use this work around, especially using the row.names trick to keep the metadata from my original file with the thinned occurrence records. Can you provide any additional context on this method? I'd really appreciate it.

@mlammens
Copy link
Owner

Hi @tinsman - Here's an example of what I'm talking about using the data set that is part of the spThin vignette:

  1. Thin the data set (this is the code in the vignette)
thinned_dataset_full <-
  thin( loc.data = Heteromys_anomalus_South_America, 
        lat.col = "LAT", long.col = "LONG", 
        spec.col = "SPEC", 
        thin.par = 10, reps = 100, 
        locs.thinned.list.return = TRUE, 
        write.files = FALSE, 
        write.log.file = FALSE)
  1. Get the row names as numbers from one of the thinned datasets. Here I'm just using the very first thinned data set. Also, note that I'm using the as.numeric function here to convert the "names" to numbers.

as.numeric(row.names(thinned_dataset_full[[1]]))

  1. Use these row numbers to index the original data set. Not that I'm taking advantage of using row, column indexing of the original data.frame.

Heteromys_anomalus_South_America[as.numeric(row.names(thinned_dataset_full[[1]])), ]

Hope that helps!

@tinsman
Copy link

tinsman commented Aug 11, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants