diff --git a/DESCRIPTION b/DESCRIPTION index cb0005a..e3c7e46 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,6 +14,6 @@ Imports: jsonlite, ggplot2, maps -RoxygenNote: 6.0.1 +RoxygenNote: 6.1.1 Suggests: knitr, rmarkdown, testthat VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index 3f95bd9..25c5432 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,3 +1,4 @@ +# Generated by roxygen2: do not edit by hand export(get_inat_obs) export(get_inat_obs_id) @@ -11,4 +12,3 @@ import(httr) import(jsonlite) import(maps) import(plyr) -importFrom("utils", "read.csv") diff --git a/R/get_inat_obs_project.R b/R/get_inat_obs_project.R index bf0c0bc..c51a664 100644 --- a/R/get_inat_obs_project.R +++ b/R/get_inat_obs_project.R @@ -1,31 +1,30 @@ #' Download observations or info from a project -#'@description retrieve observations from a particular iNaturalist project. This function can be used to get either observations or information from a project by project name or ID +#'@description retrieve observations from a particular iNaturalist project. This function can be used to get either observations or information from a project by project name or ID #'@param grpid Name of the group as an iNaturalist slug or group id -#'@param type Either "observations" or "info" Observations returns all observations, and "info" returns project details similar to what you can find on a project webpage. -#'@param raw True or False. If TRUE and searching for project info, returns the raw output of parsed JSON for that project. Otherwise just some basic information is returned as a list +#'@param type character Either "observations" or "info" Observations returns all observations, and "info" returns project details similar to what you can find on a project webpage. +#'@param raw logical TRUE or FALSE. If TRUE and searching for project info, returns the raw output of parsed JSON for that project. Otherwise just some basic information is returned as a list #'@details An iNaturalist slug is usually the project as single string with words seperated by hyphens. For instance, the project "State Flowers of the United States" has a slug of "state-flowers-of-the-united-states-eol-collection". This can be extracted from the URL for the project usually. The state flowers project has the following URL http://www.inaturalist.org/projects/state-flowers-of-the-united-states-eol-collection #' #'@examples \dontrun{ #' get_inat_obs_project(354, type = "observations") -#' get_inat_obs_project("crows-in-vermont", type="info",raw=FALSE) +#' get_inat_obs_project("crows-in-vermont", type="info",raw=FALSE) #'} #'@import httr jsonlite #'@export -get_inat_obs_project <- function(grpid,type = c("observations","info"), raw = F){ +get_inat_obs_project <- function(grpid, type = c("observations", "info"), raw = FALSE){ argstring = switch(match.arg(type), - observations = "obs", - info = "info") - url= paste("http://www.inaturalist.org/projects/",grpid,".json",sep="") - xx = fromJSON(content(GET(url),as="text")) - recs =xx$project_observations_count - + observations = "obs", + info = "info") + url <- paste0("http://www.inaturalist.org/projects/",grpid,".json") + xx <- fromJSON(content(GET(url), as = "text")) + recs <- xx$project_observations_count + ### Error handling for empty projects - dat = NULL + dat <- NULL if(is.null(recs))(return(dat)) - cat(paste(recs," Records\n0")) - - + cat(paste(recs," Records\n")) + if(argstring == "info"){ output <- list() output[["title"]] <- xx$title @@ -40,20 +39,40 @@ get_inat_obs_project <- function(grpid,type = c("observations","info"), raw = F) if(raw){ output[["raw"]] <- xx } - - return(output) - } else if(argstring == "obs"){ - - if (recs %% 100 == 0){loopval<-recs %/% 100} - else{loopval <-(recs %/% 100)+1} - for(i in 1:loopval){ - url1=paste("http://www.inaturalist.org/observations/project/",grpid,".csv?page=",i,"&per_page=100",sep="") - cat(paste("-",i*100,sep="")) - newdat=read.csv(url1,stringsAsFactors = FALSE) - dat=rbind(dat,newdat) } - return(dat) -} - + else if (argstring == "obs") { + per_page <- 200 + if (recs %% per_page == 0) { + loopval <- recs %/% per_page + } + if (recs >= 10000) { + cat( + "Number of observations in project greater than current API limit\nreturning the first 10000\n" + ) + loopval <- 10000 / per_page + } + else { + loopval <- (recs %/% per_page) + 1 + } + obs_list <- vector("list", loopval) + for (i in 1:loopval) { + url1 <- + paste0( + "http://www.inaturalist.org/observations/project/", grpid, + ".json?page=", i, + "&per_page=", per_page + ) + if (i == 1) { + cat(paste0("0-", per_page)) + } + if (i > 1) { + cat(paste0("-", i * per_page)) + } + obs_list[[i]] <- + fromJSON(content(GET(url1), as = "text"), flatten = TRUE) + } + project_obs <- do.call("rbind", obs_list) + return(project_obs) + } } diff --git a/README.Rmd b/README.Rmd index cf0ac35..da13889 100644 --- a/README.Rmd +++ b/README.Rmd @@ -174,7 +174,7 @@ print(place_counts$most_species[1:10,]) -## Mapping. +## Mapping Basic maps can be created as well to quickly visualize search results. Maps can either be plotted automatically `plot = TRUE` or simply return a ggplot2 object with `plot = FALSE`. This works well with single species data, but more complicated plots are best made from scratch. diff --git a/README.md b/README.md index 683127a..70cf7a4 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ vernal pool. We can then see all the species names found. vp_obs <- get_inat_obs(query = "vernal pool") head(vp_obs$species_guess) - ## [1] "Taper-leaved Earth-Moss" "Purple Crystalwort" - ## [3] "" "" - ## [5] "Green Dragon" "Blue Dasher" + ## [1] "Bolander's Sunflower" "American royal fern" + ## [3] "" "" + ## [5] "Wood Frog" "Twelve-spotted Skimmer" *Taxon query* @@ -75,13 +75,12 @@ name as an iNaturalist slug. vt_crows <- get_inat_obs_project("crows-in-vermont", type = "info", raw = FALSE) ## 164 Records - ## 0 ## Now get all the observations for that project vt_crows_obs <- get_inat_obs_project(vt_crows$id, type = "observations") ## 164 Records - ## 0-100-200 + ## 0-200 *Get observation details* @@ -93,19 +92,19 @@ search. head(get_inat_obs_id(m_obs$id[1])) ## $id - ## [1] 25931124 + ## [1] 28657566 ## ## $observed_on - ## [1] "2019-05-28" + ## [1] "2019-07-09" ## ## $description ## NULL ## ## $latitude - ## [1] "22.9890791803" + ## [1] "42.0774822254" ## ## $longitude - ## [1] "87.0069527811" + ## [1] "-83.1035997957" ## ## $map_scale ## NULL @@ -119,20 +118,20 @@ quite large (easily into the 1000’s). m_obs <- get_inat_obs(query = "Monarch Butterfly") head(get_inat_obs_user(as.character(m_obs$user_login[1]), maxresults = 20))[,1:5] - ## scientific_name datetime description - ## 1 Danaus chrysippus 2019-05-28 09:23:00 +0530 NA - ## 2 Junonia almana 2019-05-28 09:20:00 +0530 NA - ## 3 Junonia almana 2019-05-28 09:20:00 +0530 NA - ## 4 Catopsilia pyranthe 2019-05-28 09:19:00 +0530 NA - ## 5 Catopsilia pyranthe 2019-05-28 09:19:00 +0530 NA - ## 6 Crematogaster 2019-05-28 09:17:00 +0530 NA - ## place_guess latitude - ## 1 Kadma, West Bengal 722151, India 22.98908 - ## 2 Kadma, West Bengal 722151, India 22.98908 - ## 3 Kadma, West Bengal 722151, India 22.98908 - ## 4 Kadma, West Bengal 722151, India 22.98908 - ## 5 Kadma, West Bengal 722151, India 22.98908 - ## 6 Kadma, West Bengal 722151, India 22.98908 + ## scientific_name datetime description place_guess + ## 1 Phidippus audax 2019-06-07 16:44:09 -0400 Ontario, CA + ## 2 Danaus plexippus 2019-07-09 11:16:54 -0400 Ontario, CA + ## 3 Danaus plexippus 2019-07-11 16:24:13 -0400 Ontario, CA + ## 4 Oecanthus niveus 2019-07-11 16:20:46 -0400 Ontario, CA + ## 5 Megachile mendica 2019-07-11 16:22:04 -0400 Ontario, CA + ## 6 Lestes rectangularis 2019-07-09 17:01:12 -0400 Ontario, CA + ## latitude + ## 1 42.00755 + ## 2 42.07748 + ## 3 42.01950 + ## 4 42.19113 + ## 5 42.04144 + ## 6 42.10027 *Stats by taxa* @@ -143,7 +142,7 @@ place ID (numeric ID), or user ID (string). counts <- get_inat_taxon_stats(date = "2010-06-14") print(counts$total) - ## [1] 363 + ## [1] 383 print(counts$species_counts[1:5,]) @@ -151,14 +150,14 @@ place ID (numeric ID), or user ID (string). ## 1 5 41708 Phoca vitulina species 10 ## 2 5 57495 Melitaea cinxia species 10 ## 3 3 48662 Danaus plexippus species 10 - ## 4 3 56057 Leucanthemum vulgare species 10 - ## 5 3 58484 Thymelicus lineola species 10 + ## 4 3 52766 Megaphasma denticrus species 10 + ## 5 3 56057 Leucanthemum vulgare species 10 ## taxon.default_name.id taxon.default_name.name ## 1 67153 Harbor Seal ## 2 91278 Glanville Fritillary ## 3 586653 Monarch - ## 4 924783 oxeye daisy - ## 5 455733 Essex Skipper + ## 4 83649 Giant Walkingstick + ## 5 924783 oxeye daisy ## taxon.default_name.is_valid taxon.default_name.lexicon ## 1 TRUE English ## 2 TRUE English @@ -169,40 +168,40 @@ place ID (numeric ID), or user ID (string). ## 1 41708 2008-03-19T00:35:25.000Z ## 2 57495 2010-03-17T06:57:02.000Z ## 3 48662 2014-09-11T06:50:44.683Z - ## 4 56057 2017-06-08T19:00:12.460Z - ## 5 58484 2013-06-15T13:09:14.435Z + ## 4 52766 2009-08-24T02:06:09.000Z + ## 5 56057 2017-06-08T19:00:12.460Z ## taxon.default_name.updated_at taxon.default_name.creator_id ## 1 2019-03-25T06:53:47.770Z NA ## 2 2010-03-17T06:57:02.000Z NA ## 3 2015-07-22T12:00:15.313Z NA - ## 4 2018-01-10T00:03:27.724Z 498994 - ## 5 2016-09-16T14:07:20.465Z 4079 + ## 4 2009-08-24T02:06:09.000Z NA + ## 5 2018-01-10T00:03:27.724Z 498994 ## taxon.default_name.position ## 1 0 ## 2 0 ## 3 1 - ## 4 17 - ## 5 6 + ## 4 0 + ## 5 17 ## taxon.image_url ## 1 https://static.inaturalist.org/photos/3238907/square.jpg?1459150554 ## 2 https://static.inaturalist.org/photos/5403994/square.jpg?1545659971 ## 3 https://static.inaturalist.org/photos/1477/square.jpg?1545368454 - ## 4 https://static.inaturalist.org/photos/361971/square.jpg?1444643087 - ## 5 https://static.inaturalist.org/photos/2023400/square.jpg?1434765467 + ## 4 https://static.inaturalist.org/photos/333073/square.jpg?1444606035 + ## 5 https://static.inaturalist.org/photos/361971/square.jpg?1444643087 ## taxon.iconic_taxon_name taxon.conservation_status_name ## 1 Mammalia least_concern ## 2 Insecta ## 3 Insecta - ## 4 Plantae - ## 5 Insecta + ## 4 Insecta + ## 5 Plantae print(counts$rank_counts) ## $species - ## [1] 307 + ## [1] 325 ## ## $genus - ## [1] 18 + ## [1] 19 ## ## $subspecies ## [1] 18 @@ -231,6 +230,9 @@ place ID (numeric ID), or user ID (string). ## $subfamily ## [1] 1 ## + ## $superfamily + ## [1] 1 + ## ## $tribe ## [1] 1 @@ -244,32 +246,32 @@ observation count. counts <- get_inat_user_stats(date = "2010-06-14") print(counts$total) - ## [1] 147 + ## [1] 155 print(counts$most_observations[1:10,]) - ## count user.id user.login user.name - ## 1 53 811118 sandbankspp - ## 2 24 761669 kathleenfspicer - ## 3 20 922078 hakai470 ES470: Hakai Institute - ## 4 12 357375 richardling Richard Ling - ## 5 10 9706 greglasley Greg Lasley - ## 6 9 1422334 adriao - ## 7 8 109098 leannewallis Leanne Wallis - ## 8 8 362446 pwdeacon Pat Deacon - ## 9 8 677594 nakarb Robin Bad - ## 10 8 1167914 guillaume_papuga + ## count user.id user.login user.name + ## 1 53 811118 sandbankspp + ## 2 24 761669 kathleenfspicer + ## 3 20 922078 hakai470 ES470: Hakai Institute + ## 4 12 357375 richardling Richard Ling + ## 5 12 522214 tdavenport Tripp Davenport + ## 6 10 9706 greglasley Greg Lasley + ## 7 9 1422334 adriao + ## 8 8 109098 leannewallis Leanne Wallis + ## 9 8 362446 pwdeacon Pat Deacon + ## 10 8 677594 nakarb Robin Bad ## user.user_icon_url ## 1 https://static.inaturalist.org/attachments/users/icons/811118/thumb.jpeg?1535236899 ## 2 ## 3 ## 4 https://static.inaturalist.org/attachments/users/icons/357375/thumb.jpg?1484462740 - ## 5 https://static.inaturalist.org/attachments/users/icons/9706/thumb.jpg?1533329961 - ## 6 - ## 7 https://static.inaturalist.org/attachments/users/icons/109098/thumb.jpg?1475547611 - ## 8 https://static.inaturalist.org/attachments/users/icons/362446/thumb.jpg?1546674469 - ## 9 - ## 10 https://static.inaturalist.org/attachments/users/icons/1167914/thumb.jpg?1545502057 + ## 5 https://static.inaturalist.org/attachments/users/icons/522214/thumb.jpg?1558671195 + ## 6 https://static.inaturalist.org/attachments/users/icons/9706/thumb.jpg?1533329961 + ## 7 + ## 8 https://static.inaturalist.org/attachments/users/icons/109098/thumb.jpg?1475547611 + ## 9 https://static.inaturalist.org/attachments/users/icons/362446/thumb.jpg?1546674469 + ## 10 print(counts$most_species[1:10,]) @@ -279,47 +281,46 @@ observation count. ## 3 14 922078 hakai470 ES470: Hakai Institute ## 4 10 9706 greglasley Greg Lasley ## 5 10 357375 richardling Richard Ling - ## 6 9 1422334 adriao - ## 7 8 362446 pwdeacon Pat Deacon - ## 8 8 1519122 steven307 Steven Joyner - ## 9 7 109098 leannewallis Leanne Wallis - ## 10 7 393321 tylerh + ## 6 9 522214 tdavenport Tripp Davenport + ## 7 9 1422334 adriao + ## 8 8 362446 pwdeacon Pat Deacon + ## 9 8 1519122 steven307 Steven Joyner + ## 10 7 109098 leannewallis Leanne Wallis ## user.user_icon_url ## 1 https://static.inaturalist.org/attachments/users/icons/811118/thumb.jpeg?1535236899 ## 2 ## 3 ## 4 https://static.inaturalist.org/attachments/users/icons/9706/thumb.jpg?1533329961 ## 5 https://static.inaturalist.org/attachments/users/icons/357375/thumb.jpg?1484462740 - ## 6 - ## 7 https://static.inaturalist.org/attachments/users/icons/362446/thumb.jpg?1546674469 - ## 8 https://static.inaturalist.org/attachments/users/icons/1519122/thumb.jpeg?1555274551 - ## 9 https://static.inaturalist.org/attachments/users/icons/109098/thumb.jpg?1475547611 - ## 10 https://static.inaturalist.org/attachments/users/icons/393321/thumb.jpg?1538142473 + ## 6 https://static.inaturalist.org/attachments/users/icons/522214/thumb.jpg?1558671195 + ## 7 + ## 8 https://static.inaturalist.org/attachments/users/icons/362446/thumb.jpg?1546674469 + ## 9 https://static.inaturalist.org/attachments/users/icons/1519122/thumb.jpeg?1555274551 + ## 10 https://static.inaturalist.org/attachments/users/icons/109098/thumb.jpg?1475547611 ## By place_ID vt_crows <- get_inat_obs_project("crows-in-vermont", type = "info", raw = FALSE) ## 164 Records - ## 0 place_counts <- get_inat_user_stats(place = vt_crows$place_id) print(place_counts$total) - ## [1] 4931 + ## [1] 5536 print(place_counts$most_observations[1:10,]) ## count user.id user.login user.name - ## 1 41369 12158 erikamitchell Erika Mitchell - ## 2 27782 2179 charlie Charlie Hohn - ## 3 12341 12610 susanelliott Susan Elliott - ## 4 7598 12045 larry522 Larry Clarfeld - ## 5 7553 12036 zaccota Zac Cota - ## 6 6357 317 kpmcfarland Kent McFarland - ## 7 5838 28921 rwp84 roy pilcher - ## 8 5700 108365 judywelna - ## 9 5250 11792 kylejones Kyle Jones - ## 10 4634 6624 joannerusso + ## 1 41694 12158 erikamitchell Erika Mitchell + ## 2 28614 2179 charlie Charlie Hohn + ## 3 13096 12610 susanelliott Susan Elliott + ## 4 7887 12045 larry522 Larry Clarfeld + ## 5 7680 12036 zaccota Zac Cota + ## 6 6440 317 kpmcfarland Kent McFarland + ## 7 6165 28921 rwp84 roy pilcher + ## 8 6144 108365 judywelna + ## 9 5268 11792 kylejones Kyle Jones + ## 10 5162 6624 joannerusso ## user.user_icon_url ## 1 https://static.inaturalist.org/attachments/users/icons/12158/thumb.jpg?1558486310 ## 2 https://static.inaturalist.org/attachments/users/icons/2179/thumb.jpg?1475528361 @@ -330,35 +331,35 @@ observation count. ## 7 https://static.inaturalist.org/attachments/users/icons/28921/thumb.jpg?1475542431 ## 8 https://static.inaturalist.org/attachments/users/icons/108365/thumb.jpg?1475547470 ## 9 https://static.inaturalist.org/attachments/users/icons/11792/thumb.jpg?1475533125 - ## 10 https://static.inaturalist.org/attachments/users/icons/6624/thumb.jpg?1557081365 + ## 10 https://static.inaturalist.org/attachments/users/icons/6624/thumb.jpeg?1562532360 print(place_counts$most_species[1:10,]) ## count user.id user.login user.name - ## 1 2448 12158 erikamitchell Erika Mitchell - ## 2 2013 12045 larry522 Larry Clarfeld - ## 3 1986 12610 susanelliott Susan Elliott - ## 4 1666 2179 charlie Charlie Hohn - ## 5 1489 1088797 montpelierbioblitz1 Montpelier BioBlitz - ## 6 1449 11792 kylejones Kyle Jones - ## 7 1443 6624 joannerusso - ## 8 1283 317 kpmcfarland Kent McFarland - ## 9 1211 108365 judywelna - ## 10 1073 12049 gaudettelaura Laura Gaudette + ## 1 2444 12158 erikamitchell Erika Mitchell + ## 2 2054 12045 larry522 Larry Clarfeld + ## 3 2051 12610 susanelliott Susan Elliott + ## 4 1703 2179 charlie Charlie Hohn + ## 5 1509 6624 joannerusso + ## 6 1489 1088797 montpelierbioblitz1 Montpelier BioBlitz + ## 7 1453 11792 kylejones Kyle Jones + ## 8 1289 317 kpmcfarland Kent McFarland + ## 9 1261 108365 judywelna + ## 10 1086 12049 gaudettelaura Laura Gaudette ## user.user_icon_url ## 1 https://static.inaturalist.org/attachments/users/icons/12158/thumb.jpg?1558486310 ## 2 https://static.inaturalist.org/attachments/users/icons/12045/thumb.jpg?1475533238 ## 3 https://static.inaturalist.org/attachments/users/icons/12610/thumb.jpg?1475533475 ## 4 https://static.inaturalist.org/attachments/users/icons/2179/thumb.jpg?1475528361 - ## 5 - ## 6 https://static.inaturalist.org/attachments/users/icons/11792/thumb.jpg?1475533125 - ## 7 https://static.inaturalist.org/attachments/users/icons/6624/thumb.jpg?1557081365 + ## 5 https://static.inaturalist.org/attachments/users/icons/6624/thumb.jpeg?1562532360 + ## 6 + ## 7 https://static.inaturalist.org/attachments/users/icons/11792/thumb.jpg?1475533125 ## 8 https://static.inaturalist.org/attachments/users/icons/317/thumb.jpg?1475527502 ## 9 https://static.inaturalist.org/attachments/users/icons/108365/thumb.jpg?1475547470 ## 10 https://static.inaturalist.org/attachments/users/icons/12049/thumb.jpg?1475533241 -Mapping. --------- +Mapping +------- Basic maps can be created as well to quickly visualize search results. Maps can either be plotted automatically `plot = TRUE` or simply return diff --git a/README_files/figure-markdown_strict/unnamed-chunk-14-1.png b/README_files/figure-markdown_strict/unnamed-chunk-14-1.png index e7277ca..01af9e0 100644 Binary files a/README_files/figure-markdown_strict/unnamed-chunk-14-1.png and b/README_files/figure-markdown_strict/unnamed-chunk-14-1.png differ diff --git a/man/get_inat_obs.Rd b/man/get_inat_obs.Rd index d4ef65f..acaac35 100644 --- a/man/get_inat_obs.Rd +++ b/man/get_inat_obs.Rd @@ -2,71 +2,72 @@ % Please edit documentation in R/get_inat_obs.R \name{get_inat_obs} \alias{get_inat_obs} -\title{Download inaturalist data} +\title{Download iNaturalist data} \usage{ get_inat_obs(query = NULL, taxon_name = NULL, taxon_id = NULL, - quality = NULL, geo = NULL, year = NULL, month = NULL, day = NULL, - bounds = NULL, maxresults = 100, meta = FALSE) + quality = NULL, geo = NULL, year = NULL, month = NULL, + day = NULL, bounds = NULL, maxresults = 100, meta = FALSE) } \arguments{ -\item{query}{Query string for a general search} +\item{query}{Query string for a general search.} -\item{taxon_name}{Filter by iNat taxon name. Note that this will also select observations of -descendant taxa. Note that names are not unique, so if the name matches multiple taxa, no +\item{taxon_name}{Filter by iNat taxon name. Note that this will also select observations of +descendant taxa. Note that names are not unique, so if the name matches multiple taxa, no observations may be returned.} \item{taxon_id}{Filter by iNat taxon ID. Note that this will also select observations of descendant taxa.} -\item{quality}{the quality grade to be used. Must be either "casual" or "research" If left +\item{quality}{The quality grade to be used. Must be either "casual" or "research". If left blank both will be returned.} -\item{geo}{flag for returning only results that are georeferenced, TRUE will exclude +\item{geo}{Flag for returning only results that are georeferenced, TRUE will exclude non-georeferenced results, but they cannot be excluded.} -\item{year}{return observations only in that year (can only be one year, not a range of years)} +\item{year}{Return observations only in that year (can only be one year, not a range of years).} -\item{month}{return observations only by month, must be numeric, 1...12} +\item{month}{Return observations only by month, must be numeric, 1...12} -\item{day}{return observations only on a given day of the month, 1...31} +\item{day}{Return observations only on a given day of the month, 1...31} -\item{bounds}{a bounding box of longitude (-180 to 180) and latitude (-90 to 90) to search -within. It is a vector in the form of southern latitude, western longitude, northern latitude, -and easter longitude} +\item{bounds}{A bounding box of longitude (-180 to 180) and latitude (-90 to 90) to search +within. It is a vector in the form of southern latitude, western longitude, northern latitude, +and eastern longitude.} -\item{maxresults}{the maximum number of results to return} +\item{maxresults}{The maximum number of results to return. Should not be +a number higher than 10000.} \item{meta}{(logical) If TRUE, the output of this function is a list with metadata on the output and a data.frame of the data. If FALSE (default), just the data.frame.} } \value{ -a dataframe of the number of observations requestsed +A dataframe of the number of observations requested. } \description{ -Primary function to retrieve observations from iNaturalist, allows users to search -for data, or just filter results by a subset of what is offered by the API +Primary function to retrieve observations from iNaturalist, allows users to search +for data, or just filter results by a subset of what is offered by the API. } \note{ -Filtering doesn't always work with the query parameter for some reason (a problem on -the API end). If you want to filter by time, it's best to use the scientific name and put it -in the 'taxa' field, and not in the query field. Another issue is that the query parameter -will search the entire entry, so it is possible to get unintended results. Depending on your +Filtering doesn't always work with the query parameter for some reason (a problem on +the API end). If you want to filter by time, it's best to use the scientific name and put it +in the 'taxa' field, and not in the query field. Another issue is that the query parameter +will search the entire entry, so it is possible to get unintended results. Depending on your use case it may be advisable to use the "taxon" field instead of the query field. } \examples{ \dontrun{ ### Make a standard query - get_inat_obs(query="Monarch Butterfly") - + get_inat_obs(query = "Monarch Butterfly") + ##Filter by a bounding box of Northern California - bounds <- c(38.44047,-125,40.86652,-121.837) - get_inat_obs(query="Mule Deer", bounds=bounds) - - ## Filter with by just taxon, allows higher order filtering, - ## Here we can search for just stone flies (order plecoptera) - get_inat_obs(taxon_name="Plecoptera") - + bounds <- c(38.44047, -125, 40.86652, -121.837) + get_inat_obs(query = "Mule Deer", bounds = bounds) + + ## Filter with by just taxon, allows higher order filtering, + ## Here we can search for just stone flies (order Plecoptera) + get_inat_obs(taxon_name = "Plecoptera") + ## get metadata (the number of results found on the server) - out <- get_inat_obs(query="Monarch Butterfly", meta=TRUE) + out <- get_inat_obs(query = "Monarch Butterfly", meta = TRUE) out$meta } } diff --git a/man/get_inat_obs_project.Rd b/man/get_inat_obs_project.Rd index 566eb9a..3058a8b 100644 --- a/man/get_inat_obs_project.Rd +++ b/man/get_inat_obs_project.Rd @@ -4,17 +4,18 @@ \alias{get_inat_obs_project} \title{Download observations or info from a project} \usage{ -get_inat_obs_project(grpid, type = c("observations", "info"), raw = F) +get_inat_obs_project(grpid, type = c("observations", "info"), + raw = FALSE) } \arguments{ \item{grpid}{Name of the group as an iNaturalist slug or group id} -\item{type}{Either "observations" or "info" Observations returns all observations, and "info" returns project details similar to what you can find on a project webpage.} +\item{type}{character Either "observations" or "info" Observations returns all observations, and "info" returns project details similar to what you can find on a project webpage.} -\item{raw}{True or False. If TRUE and searching for project info, returns the raw output of parsed JSON for that project. Otherwise just some basic information is returned as a list} +\item{raw}{logical TRUE or FALSE. If TRUE and searching for project info, returns the raw output of parsed JSON for that project. Otherwise just some basic information is returned as a list} } \description{ -retrieve observations from a particular iNaturalist project. This function can be used to get either observations or information from a project by project name or ID +retrieve observations from a particular iNaturalist project. This function can be used to get either observations or information from a project by project name or ID } \details{ An iNaturalist slug is usually the project as single string with words seperated by hyphens. For instance, the project "State Flowers of the United States" has a slug of "state-flowers-of-the-united-states-eol-collection". This can be extracted from the URL for the project usually. The state flowers project has the following URL http://www.inaturalist.org/projects/state-flowers-of-the-united-states-eol-collection @@ -22,6 +23,6 @@ An iNaturalist slug is usually the project as single string with words seperated \examples{ \dontrun{ get_inat_obs_project(354, type = "observations") - get_inat_obs_project("crows-in-vermont", type="info",raw=FALSE) + get_inat_obs_project("crows-in-vermont", type="info",raw=FALSE) } }