Skip to content

Issues with Getting Points in Contour CSV files in grouping loop #33

Description

@nffarabaugh

Running my grouping loop in PlotRaster returns an error I am pretty sure corresponds with something wrong in the xlatlong command, but I can't figure out what I am doing wrong! Here is the error with the code:

plot group-level UD-rasters

for (i in seq_len(nrow(bins))) {

  • sp <- bins$species_common[i]; se <- bins$sex[i]; sc<- bins$size_catagory[i]; message("\nNow plotting UDs for ", sp, se, sc)
  • movegroup::plotraster(
  • x = file.path(saveloc, sp, se, sc, "Scaled", "All_Rasters_Scaled_Weighted_UDScaled.asc"), # Path to scaled raster generated by movegroup and scaleraster
    
  • crsloc = file.path(saveloc, sp, se, sc), # Location of saved CRS Rds file from movegroup.R
    
  • xlatlon= file.path(saveloc, sp, se, sc, "Scaled", "All_Rasters_Scaled_Weighted_LatLon.asc"),
    
  • locationpoints = aa3.df_i,
    
  • pointsincontourssave = file.path(saveloc, sp, se, sc, "Scaled", "pointsincontours.csv"),
    
  • mapsource = "google", maptype = "satellite", # Map source and type for ggmap::get_map() and ggmap::get_map() param maptype.
    
  • gmapsAPI = "YourAPI_KEY", # Enter your stadia API here, quoted character string. See Details for instructions
    
  • expandfactor = 1.1, # Extents expansion factor for basemap
    
  • mapzoom = 13, # Highest number = zoomed in. Google: 3 (continent) - 21 (building). stamen: 0-18.
    
  • savedir = file.path(saveloc, sp, se, sc, "Scaled"), # # Save outputs to a directory. Saveloc used here is a user-specified file.path. sp and se are the unique values for the grouping variables and are needed if you want to save your outputs in the correct subdirectories automatically.
    
  • receiverlats = station_latlon_df$lat,
    
  • receiverlons = station_latlon_df$lon,
    
  • receivernames = station_latlon_df$station_name)
    
  • }

Now plotting UDs for blacktip_reefFYoungofYear
ℹ Replacing old key (#######) with new key in /Users/uwtetiaroasharks/.Renviron
! Bounding box given to Google - spatial extent only approximate.
ℹ https://maps.googleapis.com/maps/api/staticmap?center=-17.017659,-149.564065&zoom=13&size=640x640&scale=2&maptype=satellite&language=en-EN&key=xxx
Error: unable to find an inherited method for function ‘crs<-’ for signature ‘x = "character"’

And Here is plotraster code without the arguments for the points in contour that runs just fine:

plot group-level UD-rasters

for (i in seq_len(nrow(bins))) {
sp <- bins$species_common[i]; se <- bins$sex[i]; sc<- bins$size_catagory[i]; message("\nNow plotting UDs for ", sp, se, sc)
movegroup::plotraster(
x = file.path(saveloc, sp, se, sc, "Scaled", "All_Rasters_Scaled_Weighted_UDScaled.asc"), # Path to scaled raster generated by movegroup and scaleraster
crsloc = file.path(saveloc, sp, se, sc), # Location of saved CRS Rds file from movegroup.R
mapsource = "google", maptype = "satellite", # Map source and type for ggmap::get_map() and ggmap::get_map() param maptype.
gmapsAPI = "YOUR API KEY HERE", # Enter your stadia API here, quoted character string. See Details for instructions
expandfactor = 1.1, # Extents expansion factor for basemap
mapzoom = 13, # Highest number = zoomed in. Google: 3 (continent) - 21 (building). stamen: 0-18.
savedir = file.path(saveloc, sp, se, sc, "Scaled")) # # Save outputs to a directory. Saveloc used here is a user-specified file.path. sp and se are the unique values for the grouping variables and are needed if you want to save your outputs in the correct subdirectories automatically.
}
message("\033[1;32m\ndBGB space-use analysis completed in ",
round(difftime(Sys.time(), t_start, units = "mins"), 0), " minutes\033[0m"); beep(8)
}

Any ideas what I am doing wrong here! Thanks a million!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions