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

RSF Workflow #10

Open
benscarlson opened this issue Mar 2, 2020 · 0 comments
Open

RSF Workflow #10

benscarlson opened this issue Mar 2, 2020 · 0 comments

Comments

@benscarlson
Copy link

benscarlson commented Mar 2, 2020

Hello,

I'm attempting to use amt in the typical create random points/extract covariates workflow, but I'm running into some problems. I'm not sure if this is the right place to post questions but here goes.

dat <- read_csv('my_data.csv',col_types=cols()) #x,y data for rsf, in lon/lat
rast <- raster('my_layer.tif') #also lon/lat, epsg:4326

The most straightforward approach is to do the following

 dat %>% 
  make_track(lon,lat,crs = CRS('+init=epsg:4326')) %>%
  random_points %>%
  extract_covariates(rast)

This works but this gives me warning messages (below). I assume because random_points uses sf internally, which doesn't work as well with spherical coordinates.

although coordinates are longitude/latitude, st_intersects assumes that they are planar

Converting to a flat projection then seems to require a fairly convoluted workflow to extract covariates. In addition, the random points object needs to be a spatial object in order to transform coordinates, but using make_track drops the case_ column.

dat %>% 
  make_track(lon,lat,crs = CRS('+init=epsg:4326')) %>%
  transform_coords(CRS('+init=epsg:3035')) %>%
  random_points %>%
  make_track(x_,y_,crs = CRS('+init=epsg:3035')) %>%
  transform_coords('+init=epsg:4326') %>%
  extract_covariates(rast)
  • It might be nice if random_points could accept a bounding box (or any polygon) in the coordinates system that matches the tracks, instead of forcing mcp or kde.
  • Also it might be nice if random points was a spatial object, such as an sf object, so that it's easy to do transformations on the points.
  • Is there a good way to tell make_track to keep all the columns in the data frame? There might be but I can't figure it out.
  • Finally, it would be nice if extract_covariates converted to the coordinate system of the raster before doing extraction. This is what raster::extract usually does, and I see in the code that extract_covariates is internally using raster::extract, but if using amt I have to explicitly do the conversion.

Thank you for the help!

Ben

@benscarlson benscarlson changed the title Workflow RSF Workflow Mar 2, 2020
@jmsigner jmsigner self-assigned this Mar 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants