Search queries automatization using R

A language for statistical computations R (S-plus) is widely used in a variety of scientific and applied problems dealing with data analysis.

Since the time of its creation a lot of useful packages were developed. This set of packages has been grown in a large R-ecosystem, allowing to solve different scientific problems and perform automatization of data analysis workflows.

Executable code in this document is given in the blocks of the form In[xxx]; these blocks could be executed via R-interpreter (e.g. R-console) in a one-by-one way, or previously saved as a text file with .r extension (r-script file).

This document is created via Jupyter and IRkernel.

Building a computational environment

Automatization of search queries in R includes:

  • Building an HTTP-request to the server according to HTTP-API;
  • Transformation of the answer, a JSON-response, in a form usual for R-environment (e.g. data.frame object);

To handle these steps the R-ecosystem includes a lot of packages. We will use the one called jsonlite, that allows automatic transformation of received data into R - data.frame objects.

So, if your local R-environment doesn't include jsonlite and curl packages, you will need to install them using install.packages(c('jsonlite', 'curl')). In this case, jsonlite is used to parse and interpret json-data recieved from the server, and curl allows to do this recieving.

In [2]:
library(jsonlite)
In [3]:
data<-fromJSON('http://botsad.ru/hitem/json/?collectedby=Пименова')
In [4]:
data$data
species_authorshipupdatedfamilyacronymspecies_statussignificancegpsbasedspecies_epithetcountryidentification_finishedcollection_finishedbranchshort_notelatituderegiongenusfieldidinfraspecific_epithettype_statusdetails
(Spenn.) Fée 2017-06-13 DRYOPTERIDACEAE VBGI From plantlist FALSE braunii Russia 43.06703 Приморский край Polystichum NA г. Ливадийская (Фалаза), кедрово-широколиственный лес
Hara 2017-06-13 CRASSULACEAE VBGI From plantlist TRUE iwarenge Russia 42.89162 Приморский край Orostachys NA Залив Восток, база "Восток", мыс Пашинникова, скалы на берегу моря
Chaix 2017-06-13 JUNCACEAE VBGI From plantlist FALSE alpinoarticulatus Russia 2015-04-01 45.82908 Приморский край Juncus NA с. Амгу, близ устья р. Амгу
Willd. ex Schult. & Schult.f. 2017-06-13 AMARYLLIDACEAE VBGI From plantlist TRUE splendens Russia 2015-04-01 45.89254 Приморский край Allium NA г. Туман, щебнистая осыпь в подгольцовом поясе
(Regel) Sojak 2017-06-13 POLYGONACEAE VBGI From plantlist TRUE maackianum Russia 42.45782 Приморский край Truellum NA оз. Лотос, на сплавине
(Regel) Sojak 2017-06-13 POLYGONACEAE VBGI From plantlist TRUE maackianum Russia 42.45782 Приморский край Truellum NA оз. Лотос, на сплавине
(Regel) Sojak 2017-06-13 POLYGONACEAE VBGI From plantlist TRUE maackianum Russia 42.45782 Приморский край Truellum NA оз. Лотос, на сплавине
(Maxim.) Maxim. ex Franch. & Sav. 2017-07-13 CUCURBITACEAE VBGI From plantlist TRUE lobatum Russia 42.45782 Приморский край Actinostemma NA оз. Лотос, на сплавине
(Buch.-Ham. ex Roxb.) Maxim. 2017-06-13 LAMIACEAE VBGI From plantlist TRUE dianthera Russia 42.45782 Приморский край Mosla NA оз. Лотос, на сплавине
(Buch.-Ham. ex Roxb.) Maxim. 2017-06-13 LAMIACEAE VBGI From plantlist TRUE dianthera Russia 42.45782 Приморский край Mosla NA оз. Лотос, на сплавине
Makino 2017-06-13 LAMIACEAE VBGI From plantlist TRUE jatabeana Russia 42.45782 Приморский край Dysophylla NA оз. Лотос, на сплавине
(R. Keller) Y. Kimura 2017-06-13 HYPERICACEAE VBGI From plantlist TRUE japonicum Russia 42.45782 Приморский край Triadenum NA оз. Лотос, на сплавине
(R. Keller) Y. Kimura 2017-06-13 HYPERICACEAE VBGI From plantlist TRUE japonicum Russia 42.45782 Приморский край Triadenum NA оз. Лотос, на сплавине
Benth. 2017-06-13 OROBANCHACEAE VBGI From plantlist FALSE chinensis Russia 42.56007 Приморский край Siphonostegia NA дорога к пос. Хасан, перевал
Benth. 2017-06-13 OROBANCHACEAE VBGI From plantlist FALSE chinensis Russia 42.55994 Приморский край Siphonostegia NA дорога к пос. Хасан, перевал
Miq. 2017-06-13 SALICACEAE VBGI From plantlist FALSE pierotii Russia 42.55981 Приморский край Salix NA дорога на пос. Хасан, скала у дороги
L. 2017-06-13 SALICACEAE VBGI From plantlist FALSE caprea Russia 42.56045 Приморский край Salix NA дорога н апос. Хасан, скала у дороги
(Thunb.) Schindl. 2017-06-13 LEGUMINOSAE VBGI From plantlist FALSE striata Russia 42.55943 Приморский край Kummerowia NA дорога на пос. Хасан, скала у дороги
Miq. 2017-06-13 LEGUMINOSAE VBGI From plantlist FALSE cyrtobotrya Russia 42.47370 Приморский край Lespedeza NA перевал от оз. Лотос
Miq. 2017-06-13 LEGUMINOSAE VBGI From plantlist FALSE cyrtobotrya Russia 42.47415 Приморский край Lespedeza NA перевал от оз. Лотос
(Pall.) DC. 2017-06-13 LEGUMINOSAE VBGI From plantlist FALSE dahuricus Russia 42.87962 Приморский край Astragalus NA трасса после поворота на Славянку, обочина
Thunb. 2017-06-13 FAGACEAE VBGI From plantlist TRUE dentata Russia 42.45782 Приморский край Quercus NA оз. Лотос, берег
Thunb. 2017-06-13 FAGACEAE VBGI From plantlist TRUE dentata Russia 42.45782 Приморский край Quercus NA оз. Лотос, берег
(Siebold et Zucc.) Sojak 2017-06-13 POLYGONACEAE VBGI From plantlist TRUE thunbergii Russia 42.45782 Приморский край Truellum NA оз. Лотос, на сплавине
(Siebold et Zucc.) Sojak 2017-06-13 POLYGONACEAE VBGI From plantlist TRUE thunbergii Russia 42.45782 Приморский край Truellum NA оз. Лотос, на сплавине
Hance 2017-06-13 COMPOSITAE VBGI From plantlist FALSE sinica Russia 42.44926 Приморский край Anaphalis NA оз. Лотос, разреженный дубняк
Willd. 2017-06-13 COMPOSITAE VBGI From plantlist FALSE parviflora Russia 42.55994 Приморский край Bidens NA дорога к пос. Хасан, скала у дороги
Planch. 2017-06-13 LINACEAE VBGI From plantlist FALSE stelleroides Russia 42.55918 Приморский край Linum NA дорога к пос. Хасан, скала, обочина дороги
Maxim. 2017-06-13 ORCHIDACEAE VBGI From plantlist TRUE hologlottis Russia 42.53378 Приморский край Platanthera NA небольшой перевал к оз. Птичье, сырой луг
Maxim. 2017-06-13 ORCHIDACEAE VBGI From plantlist TRUE hologlottis Russia 42.53378 Приморский край Platanthera NA небольшой перевал к оз. Птичье, сырой луг
Rupr. 2017-11-14 ASPLENIACEAE VBGI From plantlist FALSE sibiricus Russia 43.46002 Приморский край Camptosorus NA Борисовское плато, верх. течение р. Нежинка, на скалах.
Rupr. 2017-11-14 ASPLENIACEAE VBGI From plantlist TRUE sibiricus Russia 43.28614 Приморский край Camptosorus NA верховья р. Амба, правый берег (хр. Скалистый), сев. эксп. ниже водорахдела, замшелая скала.
Hayata 2017-11-14 ASPLENIACEAE VBGI From plantlist FALSE tenuicaule Russia 43.28614 Приморский край Asplenium NA р. Амба, правый берег, водораздел руч. Пятый и руч. Четвертый, скалы сев. эксп. под хребтом, влажные и тенистые.
Hayata 2017-11-15 ASPLENIACEAE VBGI From plantlist FALSE tenuicaule Russia 43.28614 Приморский край Asplenium NA верховье р. Амба, правый берег (хр. Скалистый), сев. эксп. ниже водораздела, замшелая скала.
Hayata 2017-11-15 ASPLENIACEAE VBGI From plantlist FALSE tenuicaule Russia 43.46846 Приморский край Asplenium NA Борисовское плато,верх. течение р. Нежинка, долина руч. Раздольненский, на скалах.
Regel & Maack 2017-11-16 POLYPODIACEAE VBGI Approved TRUE ussuriensis Russia 43.28614 Приморский край Pleopeltis NA верх. р. Амба, верх. р.Четвертый и Пятый, влажные и тенистые скалы со стороны реки, ниже водораздела.
Regel & Maack 2017-11-16 POLYPODIACEAE VBGI Approved FALSE ussuriensis Russia 43.47434 Приморский край Pleopeltis NA Борисовское плато, верх. теч. р. Нежинка, водораздел р. Нежинка и руч. Форелевый, скалистый гребень.
Regel & Maack 2017-11-16 POLYPODIACEAE VBGI Approved FALSE ussuriensis Russia 43.49029 Приморский край Pleopeltis NA Борисовское плато, верх. теч. р. Нежинка, водораздел руч. Раздольненский и р. Вторая Речка, скалистый гребень.
Regel & Maack 2017-11-16 POLYPODIACEAE VBGI Approved FALSE ussuriensis Russia 43.47434 Приморский край Pleopeltis NA Борисовское плато, верх. теч. р. Нежинка, выше устья руч. Раздольненский, на стволе дерева.
L. 2017-11-20 EQUISETACEAE VBGI From plantlist FALSE arvense Russia 43.61518 Приморский край Equisetum NA нац. парк Зов Тигра, г. Победа, зап. склон, елово-пихтовый лес в ср. части.
L. 2017-11-20 EQUISETACEAE VBGI From plantlist TRUE arvense Russia 43.48554 Приморский край Equisetum NA р. Нежинка, пойма.
L. 2017-11-20 EQUISETACEAE VBGI From plantlist FALSE arvense Russia 43.48554 Приморский край Equisetum NA Борисовское плато, верх. течение р. Нежинка, выше устья руч. Раздольненский, долинный лес.
L. 2017-11-20 EQUISETACEAE VBGI From plantlist TRUE arvense Russia 42.78200 Приморский край Equisetum NA с. Цуканово, долина реки у заставы, лиственный лес.
L. 2017-11-20 EQUISETACEAE VBGI From plantlist TRUE arvense Russia 42.78200 Приморский край Equisetum NA с. Цуканово, долина реки у заставы, лиственный лес.
L. 2017-11-20 EQUISETACEAE VBGI From plantlist TRUE arvense Russia 43.31606 Приморский край Equisetum NA р. Амба, водораздел руч. Пятый и его левого притока, лиственный лес.
L. 2017-11-20 EQUISETACEAE VBGI From plantlist FALSE arvense Russia 50.33339 Приморский край Equisetum NA около 5 км от с. Овчинниково за запад, среднее течение р. Барабашевка, надпойменная терраса, лиственный лес.
L. 2017-11-20 EQUISETACEAE VBGI From plantlist FALSE arvense Russia 50.33339 Приморский край Equisetum NA около 5 км от с. Овчинниково за запад, среднее течение р. Барабашевка, надпойменная терраса, лиственный лес.
L. 2017-11-24 AMARANTHACEAE VBGI From plantlist FALSE polyspermum Russia 2017-08-09 2017-08-09 43.22431 Приморский край Chenopodium NA Ботанический сад-институт ДВО РАН, экспозиция лаборатории флоры Дальнего Востока, в зарослях мыльнянки лекарственной
L. 2017-12-01 EQUISETACEAE VBGI From plantlist TRUE hyemale Russia 43.36229 Приморский край Equisetum NA р. Грязная, долинный лес в окр. кордона.
L. 2017-12-01 EQUISETACEAE VBGI From plantlist FALSE hyemale Russia 43.46114 Приморский край Equisetum NA Борисовское плато, верх. течение р. Нежинка, долина реки выше устья руч. Раздольненский, смешанный лес.
L. 2017-12-01 EQUISETACEAE VBGI From plantlist TRUE hyemale Russia 43.61518 Приморский край Equisetum NA нац. парк "Зов тигра", г. Победа, подножье зап. склона, влажный березово-ольховый лес.
Ehrh. 2017-12-04 EQUISETACEAE VBGI From plantlist FALSE pratense Russia 43.46064 Приморский край Equisetum NA Борисовское плато, верх. течение р. Нежинка, водораздел руч. Раздольненский и р. Вторая речка, мочажина, смешанный лес.
Ehrh. 2017-12-04 EQUISETACEAE VBGI From plantlist TRUE pratense Russia 43.36229 Приморский край Equisetum NA р. Грязная, долинный лес в окр. кордона.
L. 2017-12-06 EQUISETACEAE VBGI From plantlist TRUE sylvaticum Russia 43.31606 Приморский край Equisetum NA р. Амба, водораздел руч. Пятый и его левого притока, лиственный лес.
L. 2017-12-06 EQUISETACEAE VBGI From plantlist TRUE sylvaticum Russia 43.31606 Приморский край Equisetum NA р. Амба, водораздел руч. Пятый и его левого притока, лиственный лес.
L. 2017-12-06 EQUISETACEAE VBGI From plantlist TRUE sylvaticum Russia 43.23702 Приморский край Equisetum NA 5 км на запад от с. Овчинниково, ср. течение р. Барабашевка, надпойменная терраса, лиственный лес.
(Fisch.) Juz. 2017-12-10 ROSACEAE ABGI Approved FALSE parvifolia Mongolia 2017-09-08 2016-07-21 48.05605 Dasiphora NA Природный участок университета
(L.) Holub 2017-12-14 LYCOPODIACEAE VBGI From plantlist TRUE complanatum Russia Herbarium of Vascular Plants 45.89312 Приморский край Diphasiastrum NA Верховья р. Средняя Амгу, левый берег, хвойно-широколиственный лес.
(L.) Holub 2017-12-14 LYCOPODIACEAE VBGI From plantlist FALSE complanatum Russia Herbarium of Vascular Plants 45.89312 Приморский край Diphasiastrum NA Верховья р. Средняя Амгу, левый берег, хвойно-широколиственный лес.
(L.) Holub 2017-12-14 LYCOPODIACEAE VBGI From plantlist FALSE complanatum Russia Herbarium of Vascular Plants 45.89312 Приморский край Diphasiastrum NA Верховья р. Средняя Амгу, левый берег, хвойно-широколиственный лес.

To build more complex search requests, it is recommended to decompose them using lists of parameters:

In [5]:
http_api_base_url <- 'http://botsad.ru/hitem/json/?'
search_parameters <- c('collectedby', 'Пименова', 'identifiedby', 'Крестов')

In this case, parameters along with their values are defined in the search_parameters variable; further, we can use function paste, to form the search url. Building a search url from a set of parameters assumes getting a string including the http_api_base_url variable and a substring including parameters' names and values separated by symbol &.

In [6]:
search_url <- paste(http_api_base_url, paste(search_parameters[c(TRUE, FALSE)], search_parameters[c(FALSE, TRUE)], sep='=', collapse='&'), sep='')

Ok, the search url is formed now. Let's query the server for data.

In [7]:
new_data <- fromJSON(search_url)
In [8]:
dim(new_data$data)
  1. 2
  2. 42
In [9]:
new_data$data
species_authorshipupdatedfamilyacronymspecies_statussignificancegpsbasedspecies_epithetcountryidentification_finishedcollection_finishedbranchshort_notelatituderegiongenusfieldidinfraspecific_epithettype_statusdetails
Tzvelev 2017-06-13 DRYOPTERIDACEAE VBGI From plantlist FALSE subtripteron 2014-05-20 43.53312 Приморский край Polystichum NA Борисовское плато. верх. течение р. Нежинка, р. Раздольненский, долинный смешанный лес на надпойменной террасе.
Tzvelev 2017-06-13 DRYOPTERIDACEAE VBGI From plantlist FALSE subtripteron 43.44694 Приморский край Polystichum NA Борисовское плато, верх. течение р. Нежинка, выше устья руч. Раздольненский, долинный смешанный лес на надпойменной террасе.

Nested data structures, such as dethistory and additionals fields, are correctly transformed into data.frames via fromJSON utility function.

In [10]:
new_data$data$dethistory
  1. species_authorshipfamilyspecies_statusspecies_epithetinfraspecific_authorshipinfraspecific_rankgenus_authorshipspecies_fullnamespecies_idvalid_fromidentifiersfamily_authorshipvalid_tosignificancegenusinfraspecific_epithet
    Tzvelev DRYOPTERIDACEAE From plantlist subtripteron Polystichum subtripteron Tzvelev216942 2016-09-17 Храпко О.В. Polystichum

It is useful to assign a special variable to data$data, e.g. my_data, to access the data directly.

In [11]:
my_data <- data$data

Let's count familys' frequencies in the retrieved data.

In [12]:
data.frame(table(my_data$family))
Var1Freq
ACORACEAE 1
ACTINIDIACEAE 4
ADOXACEAE 14
ALISMATACEAE 1
ALLISONIACEAE 2
AMARANTHACEAE 2
AMARYLLIDACEAE 10
APIACEAE 23
APOCYNACEAE 3
AQUIFOLIACEAE 1
ARACEAE 11
ARALIACEAE 13
ARISTOLOCHIACEAE 9
ASPARAGACEAE 17
ASPLENIACEAE 10
ATHYRIACEAE 78
AYTONIACEAE 1
BERBERIDACEAE 8
BETULACEAE 21
BORAGINACEAE 16
BRASSICACEAE 26
CAMPANULACEAE 4
CAPRIFOLIACEAE 19
CARYOPHYLLACEAE 22
CELASTRACEAE 2
CHLORANTHACEAE 5
COMPOSITAE 58
CONOCEPHALACEAE 2
CRASSULACEAE 9
CUCURBITACEAE 1
PHRYMACEAE 1
PINACEAE 9
PLANTAGINACEAE 1
POACEAE 61
POLEMONIACEAE 2
POLYGALACEAE 1
POLYGONACEAE 7
POLYPODIACEAE 14
PONTEDERIACEAE 1
POTAMOGETONACEAE 1
PRIMULACEAE 7
PTERIDACEAE 20
RANUNCULACEAE 51
RHAMNACEAE 14
ROSACEAE 76
RUBIACEAE 18
RUTACEAE 5
SALICACEAE 65
SANTALACEAE 5
SAPINDACEAE 17
SAXIFRAGACEAE 2
SMILACACEAE 1
TAXACEAE 1
THELYPTERIDACEAE16
ULMACEAE 2
URTICACEAE 2
VIOLACEAE 46
VITACEAE 2
WOODSIACEAE 31
XANTHORRHOEACEAE 4

If one needs to compute, for example, Shannon's biodiversity index, one can use the vegan package, which includes a lot of useful functions and algorithm implementations for processing datasets typical for botany or ecology.

In [13]:
library(vegan)
Loading required package: permute
Loading required package: lattice
This is vegan 2.4-4

Shannon's biodiversity index by family field:

In [14]:
diversity(table(my_data$family))
3.92193849041052

Exporting data to a CSV file

Loaded into the R statistical environment data could be saved as a csv-formatted file using R-language facilities. This is useful when planning to process the data using MS Excel-like software.

Let's consider hypotetical example of exporting all records belonging to family ARALIACEAE; Additionaly, we require to export only a certain number of columns. As an example, we select the following columns to be exported: unique identifier of the record (ID), full name of the species (species_fullname), collectors (collectors), latitude (latitude), longitude (longitude), elevation above sea level (elevation). Exact column names are given in parentheses and coincide to the server's response parameters declared in the HTTP API docs.

In [15]:
araliaceae_records <- fromJSON('http://botsad.ru/hitem/json/?family=Araliaceae')

Show all Araliaceae's records:

In [16]:
araliaceae_records
$errors
$data
species_authorshipupdatedfamilyacronymspecies_statussignificancegpsbasedspecies_epithetcountryidentification_finishedcollection_finishedbranchshort_notelatituderegiongenusfieldidinfraspecific_epithettype_statusdetails
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE VBGI From plantlist FALSE senticosus Russia 50.27938 Хабаровский край Eleutherococcus NA Долина реки Ярап, долинный тополевый лес
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE VBGI From plantlist FALSE senticosus Russia 50.28341 Хабаровский край Eleutherococcus NA Долина реки Ярап, старица, долинный чозениево-тополевый лес
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 49.84374 Амурская область Eleutherococcus NA Муравьевский природный парк, в посадках.
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 49.84374 Амурская область Eleutherococcus NA Муравьевский природный парк, в посадках.
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 2016-08-12 2016-08-12 48.43490 Хабаровский край Eleutherococcus NA Долинный остров, лес в пойме р.Ярап.
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 2016-08-12 2016-08-12 48.43490 Хабаровский край Eleutherococcus NA р.Ярап
(Rupr. & Maxim.) S.Y.Hu 2017-06-13 ARALIACEAE ABGI From plantlist FALSE sessiliflorus Russia 1989-06-19 1989-06-19 47.87721 Еврейская Автономная Область Eleutherococcus NA Екатерино- Никольское, медвежий утес.
(Rupr. & Maxim.) S.Y.Hu 2017-06-13 ARALIACEAE ABGI From plantlist FALSE sessiliflorus Russia 1989-06-19 1989-06-19 47.79517 Еврейская Автономная Область Eleutherococcus NA Екатерино- Никольское, медвежий утес.
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 1990-08-11 1990-08-11 49.62539 Амурская область Eleutherococcus NA Остров Виноградный, пойменный лес.
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 1990-08-11 1990-08-11 49.62272 Амурская область Eleutherococcus NA Остров Виноградный.
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 2005-08-25 2005-08-25 49.12107 Амурская область Eleutherococcus NA Окрестности с.Кундур, лес.
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 2014-09-20 2014-09-20 44.09590 Приморский край Eleutherococcus NA Сихотэ-Алинь, маршрут на г. Снежная, перевал Пузико, лес.
(Nakai) Nakai 2017-06-13 ARALIACEAE ABGI From plantlist FALSE elatus Russia 2014-09-14 2014-09-14 44.09590 Приморский край Oplopanax NA Сихотэ-Алинь, маршрут на г. Снежная, перевал Пузико, лес.
(Nakai) Nakai 2017-06-13 ARALIACEAE ABGI From plantlist FALSE elatus Russia 2014-09-14 2014-09-14 44.13534 Приморский край Oplopanax NA Сихотэ-Алинь, маршрут на г. Снежная, перевал Пузико, лес.
C.A.Mey. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE ginseng Russia 44.48524 Приморский край Panax NA
C.A.Mey. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE ginseng Russia 44.53421 Приморский край Panax NA
C.A.Mey. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE ginseng Russia 44.84029 Приморский край Panax NA
C.A.Mey. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE ginseng Russia 45.58329 Приморский край Panax NA
C.A.Mey. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE ginseng Russia 45.58329 Приморский край Panax NA
C.A.Mey. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE ginseng Russia 45.58329 Приморский край Panax NA
C.A.Mey. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE ginseng Russia 45.58329 Приморский край Panax NA
C.A.Mey. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE ginseng Russia 45.58329 Приморский край Panax NA
C.A.Mey. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE ginseng Russia 45.58329 Приморский край Panax NA
C.A.Mey. 2017-06-13 ARALIACEAE ABGI From plantlist FALSE ginseng Russia 45.58329 Приморский край Panax NA
(Rupr. & Maxim.) Maxim. 2017-06-13 ARALIACEAE VBGI From plantlist FALSE senticosus Russia 50.28341 Хабаровский край Eleutherococcus NA Долина реки Ярап, старица, долинный чозениево-тополевый лес
(Rupr. & Maxim.) S.Y.Hu 2017-06-13 ARALIACEAE VBGI From plantlist TRUE sessiliflorus Russia 43.57740 Приморский край Eleutherococcus NA с. Монакино, НП Земля леопарда, ручей Каменистый, долинный лес
(Rupr. & Maxim.) S.Y.Hu 2017-06-13 ARALIACEAE VBGI From plantlist TRUE sessiliflorus Russia 43.57740 Приморский край Eleutherococcus NA с. Монакино, НП Земля леопарда, ручей Каменистый, под склоном
Kitag. 2017-03-22 ARALIACEAE VBGI From plantlist FALSE continentalis Russia Herbarium of Life forms NA Приморский край Aralia NA окр. п. Витязь, бухта Витязь, широколиственный лес по склону к морю
Kitag. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE continentalis Russia 43.38194 Приморский край Aralia NA р. Амба. Водораздел руч. Антоновского и руч. Безымянный, нижняя часть склона, смешанный лес
Kitag. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE continentalis Russia 43.39149 Приморский край Aralia NA р. Грязная, водораздел рек Левая Грязная и Ананьевка, смешанный лес
Kitag. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE continentalis Russia 43.39149 Приморский край Aralia NA р. Грязная, водораздел рек Левая Грязная и Ананьевка. Смешанный лес
Kitag. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE continentalis Russia 43.39149 Приморский край Aralia NA р. Грязная, водораздел рек Левая Грязная и Ананьевка. Смешанный лес
Kitag. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE continentalis Russia 43.39149 Приморский край Aralia NA р. Грязная, водораздел рек Левая Грязная и Ананьевка. Смешанный лес
Kitag. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE continentalis Russia 43.81050 Приморский край Aralia NA c. Цуканово, склоны г. Луна, редко
(Thunb.) Koidz. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE septemlobus Russia 43.36817 Приморский край Kalopanax NA р. Грязная, водораздел рек Левая Грязная и Ананьевка. Широколиственный лес с пихтой
(Thunb.) Koidz. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE septemlobus Russia 43.36451 Приморский край Kalopanax NA р. Грязная, р. Левая Грязная, склон, дубняк
(Thunb.) Koidz. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE septemlobus Russia 43.36451 Приморский край Kalopanax NA р. Грязная, р. Левая Грязная, склон, дубняк
(Thunb.) Koidz. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE septemlobus Russia 43.36451 Приморский край Kalopanax NA р. Грязная, р. Левая Грязная, склон, дубняк
C.A.Mey. 2017-07-11 ARALIACEAE VBGI From plantlist TRUE ginseng Russia 43.36921 Приморский край Panax NA р. Грязная, водораздел р. Левая Грязная и Ананьевка, смешанный лес
(Rupr. & Maxim.) Maxim. 2017-08-17 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 1997-08-16 1997-08-16 43.14687 Primorskiy territory Eleutherococcus 592 b NA Suburb of Vladivostok, vicinity of Academic town, broad-leaved forest, wiht Corydalis ambigua and Ranunculus ussuriensis,abundant.
(Rupr. & Maxim.) Maxim. 2017-08-17 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 1999-01-17 1998-08-02 45.16695 Приморский край Eleutherococcus NA Сихотэ-Алинский заповедник, среднее течение реки Сиды, окрестности Зимовейный, разнопородный хвойно-лмиственный лесв пойме ручьяю
(Rupr. & Maxim.) Maxim. 2017-08-17 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 1991-06-26 1991-06-26 43.14978 Primorskiy territory Eleutherococcus 592 a NA Suburb of Vladivostok, vicinity of Academic town, edge of broad-leaved forest, frequent.
(Rupr. & Maxim.) S.Y.Hu 2017-08-17 ARALIACEAE ABGI From plantlist FALSE sessiliflorus Russia 1988-08-06 1988-08-06 42.83889 Primorskiy territory Eleutherococcus 593 NA Suburb of Nakhodka, Marine biologic station 'Vostok", edge of Quercus mongolica forest, frequent.
(Thunb.) Koidz. 2017-08-17 ARALIACEAE ABGI From plantlist FALSE septemlobus Russia 1995-08-11 1995-08-11 43.15200 Primorskiy territory Kalopanax 1104 NA Suburb of Vladivostok, Academic town, broad-leaved forest, solitary trees, common.
(Rupr. & Maxim.) Maxim. 2017-08-17 ARALIACEAE ABGI From plantlist FALSE senticosus Russia 1998-10-10 1998-10-10 43.22997 Приморский край Eleutherococcus 19 NA г. Владивосток, окрестности водохранилища Седанка, склон южной экспозиции, разнопородный лиственный лес с черной пихтой.
$warnings
In [17]:
export_data <- araliaceae_records$data[,c('id','species_fullname','collectors','latitude','longitude','altitude')]

Show the data to be exported:

In [18]:
export_data
idspecies_fullnamecollectorslatitudelongitudealtitude
52 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Андышева Е.А. 50.27938 134.7095
91 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Корзников К.А. 50.28341 134.7152
612 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Морозова Г.Ю. 49.84374 127.7298 122
613 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Морозова Г.Ю. 49.84374 127.7298 122
614 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Ступникова Т.В. 48.43490 134.1659 76
615 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Ступникова Т.В. 48.43490 134.1659 76
616 Eleutherococcus sessiliflorus (Rupr. & Maxim.) S.Y.Hu Старченко В.М. 47.87721 131.0518 73
617 Eleutherococcus sessiliflorus (Rupr. & Maxim.) S.Y.Hu Старченко В.М. 47.79517 130.9927 73
618 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Старченко В.М., Елизаров А. 49.62539 127.9516 7
619 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Старченко В.М., Дарман Г.Ф. 49.62272 127.9468 7
620 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Шатохина А.В. 49.12107 130.7922 160
621 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Андышева Е.В. 44.09590 133.5153 226
622 Oplopanax elatus (Nakai) Nakai Андышева Е.В. 44.09590 133.5153 226
623 Oplopanax elatus (Nakai) Nakai Андышева Е.В. 44.13534 133.9338 266
624 Panax ginseng C.A.Mey. Горовой П.Г. 44.48524 133.7338 266
625 Panax ginseng C.A.Mey. Горовой П.Г. 44.53421 134.1898 266
626 Panax ginseng C.A.Mey. Горовой П.Г. 44.84029 134.0332 266
627 Panax ginseng C.A.Mey. Горовой П.Г. 45.58329 135.7031 266
628 Panax ginseng C.A.Mey. Горовой П.Г. 45.58329 135.7031 266
629 Panax ginseng C.A.Mey. Горовой П.Г. 45.58329 135.7031 266
630 Panax ginseng C.A.Mey. Горовой П.Г. 45.58329 135.7031 266
631 Panax ginseng C.A.Mey. Горовой П.Г. 45.58329 135.7031 266
632 Panax ginseng C.A.Mey. Горовой П.Г. 45.58329 135.7031 266
633 Panax ginseng C.A.Mey. Горовой П.Г. 45.58329 135.7031 266
1694 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Корзников К.А. 50.28341 134.7152
1979 Eleutherococcus sessiliflorus (Rupr. & Maxim.) S.Y.Hu Пименова Е.А., Баркалов В.Ю., Колдаева М.Н., Нестерова С.В., Калинкина В.А.43.57740 131.3542 470
2418 Eleutherococcus sessiliflorus (Rupr. & Maxim.) S.Y.Hu Пименова Е.А., Баркалов В.Ю., Колдаева М.Н., Нестерова С.В., Калинкина В.А.43.57740 131.3542 470
2823 Aralia continentalis Kitag. Безделева Т.А. NA NA
23750 Aralia continentalis Kitag. Колдаева М.Н., Калинкина В.А., Пименова Е.А. 43.38194 131.4121 273
23751 Aralia continentalis Kitag. Пименова Е.А., Нестерова С.В., Петруненко Е.А. 43.39149 131.4895 509
23752 Aralia continentalis Kitag. Пименова Е.А., Нестерова С.В., Петруненко Е.А. 43.39149 131.4895 509
23753 Aralia continentalis Kitag. Пименова Е.А., Нестерова С.В., Петруненко Е.А. 43.39149 131.4895 509
23754 Aralia continentalis Kitag. Пименова Е.А., Нестерова С.В., Петруненко Е.А. 43.39149 131.4895 509
23755 Aralia continentalis Kitag. Колдаева М.Н., Калинкина В.А., Пименова Е.А., Верхолат В.П. 43.81050 130.7281 426
23756 Kalopanax septemlobus (Thunb.) Koidz. Пименова Е.А., Нестерова С.В., Петруненко Е.А. 43.36817 131.5526 217
23757 Kalopanax septemlobus (Thunb.) Koidz. Пименова Е.А., Нестерова С.В., Петруненко Е.А. 43.36451 131.5535 185
23758 Kalopanax septemlobus (Thunb.) Koidz. Пименова Е.А., Нестерова С.В., Петруненко Е.А. 43.36451 131.5535 185
23759 Kalopanax septemlobus (Thunb.) Koidz. Пименова Е.А., Нестерова С.В., Петруненко Е.А. 43.36451 131.5535 185
23760 Panax ginseng C.A.Mey. Пименова Е.А., Нестерова С.В., Петруненко Е.А. 43.36921 131.4877 496
27943 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Kharkevich S., Buch T. 43.14687 132.0586 270
27944 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Кузьмин А.А. 45.16695 135.3591 400
27945 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Kharkevich S., Buch T. 43.14978 132.0514 270
27946 Eleutherococcus sessiliflorus (Rupr. & Maxim.) S.Y.Hu Kharkevich S., Buch T. 42.83889 132.8601 250
27947 Kalopanax septemlobus (Thunb.) Koidz. Kharkevich S., Buch T. 43.15200 132.0421 240
27948 Eleutherococcus senticosus (Rupr. & Maxim.) Maxim. Кузьмин А.А. 43.22997 132.0394 270
In [19]:
write.csv(export_data, file='araliacea_dataset.csv')

The write.csv function will create a file called araliacea_dataset.csv in the current working directory. One can specify a path where the file should be saved using either the setwd R-function (short for set working directory) or providing it in the file argument to the write.csv function (e.g. file="path/to/your/home/folder/araliacea_dataset.csv").

Emulation of OR-type search requests

By default Digital Herbarium HTTP API retrieves data that matches all provided search conditions (i.e. executes AND-type search queries). Moreover, in the current implementation of the HTTP API service, there is no way to build and execute OR-type search query as a single request. So, the only way to make OR-type requests is its emulation. Emulation of OR-type search requests assumes executing a sequence of requests and gluing retrieved data into single dataset.

See OR-type search request emulation in example with two search requests presented by sets of parameters search_parameters1 and search_parameters2:

In [20]:
search_parameters1 <- c('identifiedby', 'Пименова', 'collectedby', 'Пименова')
search_parameters2 <- c('identifiedby', 'Крестов', 'collectedby', 'Крестов')
search_url1 <- paste(http_api_base_url, paste(search_parameters1[c(TRUE, FALSE)], search_parameters1[c(FALSE, TRUE)], sep='=', collapse='&'), sep='')
search_url2 <- paste(http_api_base_url, paste(search_parameters2[c(TRUE, FALSE)], search_parameters2[c(FALSE, TRUE)], sep='=', collapse='&'), sep='')
In [21]:
search_url1
'http://botsad.ru/hitem/json/?identifiedby=Пименова&collectedby=Пименова'
In [22]:
search_url2
'http://botsad.ru/hitem/json/?identifiedby=Крестов&collectedby=Крестов'
In [23]:
dataset1 <- fromJSON(search_url1)
dataset2 <- fromJSON(search_url2)
In [24]:
df1<-data.frame(dataset1$data)
df2<-data.frame(dataset2$data)
In [25]:
merged_data <- rbind(df1, df2)
In [26]:
dim(df2)
dim(df1)
dim(merged_data)
  1. 181
  2. 42
  1. 1034
  2. 42
  1. 1215
  2. 42

At this step the merged_data data frame could include duplicated rows, so we need to clean-up it. To remove duplicated rows we will exploit uniqueness of the ID field: If rows have the same ID they are the same.

In [27]:
data_without_dups<-merged_data[!duplicated(merged_data$id),]
In [28]:
dim(data_without_dups)
  1. 1213
  2. 42

Perfectly, original size of the dataset was changed, i.e. some rows were excluded... So, the data_without_dups variable presents a dataset with records matching complex query defined by search_parameters1 OR search_parameters2.

Filtering data by a user defined region

Let us assume that a given region is presented as an ESRI-shape file. Since HTTP API service allows making search requests only for rectangular areas, we will divide the task into stages: 1) getting a rectangular area that includes desired contour; 2) making search query by the rectangular area; 3) excluding records lying outside of the given contour.

To read ESRI-shape files we will use rgdal package. This package uses GDAL open source library for processing geographically distributed data; this library is widely used in building various geographic information systems (GIS).

Therefore, we assume that your R-ecosystem has preinstalled rgdal package that, in its turn, assumes installed GDAL library on your system (since GDAL is included into Windows distribution of the rgdal package, existence of GDAL doesn't make sense for Windows users).

In [29]:
library('rgdal')
shape_rgdal <- readOGR(dsn=path.expand("/home/dmitry/workspace/herbs/herbs/docs/tutorial/R/ru/sakhalin"), layer="sakhalin")
Loading required package: sp
rgdal: version: 1.2-16, (SVN revision 701)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 2.1.3, released 2017/20/01
 Path to GDAL shared files: /usr/share/gdal
 GDAL binary built with GEOS: TRUE 
 Loaded PROJ.4 runtime: Rel. 4.9.2, 08 September 2015, [PJ_VERSION: 492]
 Path to PROJ.4 shared files: (autodetected)
 Linking to sp version: 1.2-5 
OGR data source with driver: ESRI Shapefile 
Source: "/home/dmitry/workspace/herbs/herbs/docs/tutorial/R/ru/sakhalin", layer: "sakhalin"
with 1 features
It has 8 fields

Ok, our shapefile was successfully loaded...

In [30]:
shape_rgdal
An object of class "SpatialPolygonsDataFrame"
Slot "data":
  iso_code level_4_na level4_cod level4_2 level3_cod level2_cod level1_cod
0       RU   Sakhalin     SAK-OO       OO        SAK         31          3
  mrgid
0 48418

Slot "polygons":
[[1]]
An object of class "Polygons"
Slot "Polygons":
[[1]]
An object of class "Polygon"
Slot "labpt":
[1] 142.71208  50.33426

Slot "area":
[1] 9.533439

Slot "hole":
[1] FALSE

Slot "ringDir":
[1] 1

Slot "coords":
           [,1]     [,2]
  [1,] 141.8425 53.14527
  [2,] 141.8364 53.14888
  [3,] 141.8319 53.15277
  [4,] 141.8272 53.16666
  [5,] 141.8094 53.25639
  [6,] 141.8105 53.29527
  [7,] 141.7708 53.35833
  [8,] 141.7647 53.36500
  [9,] 141.7669 53.37138
 [10,] 141.7780 53.37638
 [11,] 141.9814 53.45499
 [12,] 142.0922 53.49138
 [13,] 142.2136 53.51860
 [14,] 142.2269 53.51833
 [15,] 142.2519 53.48555
 [16,] 142.2539 53.47887
 [17,] 142.2514 53.47249
 [18,] 142.2397 53.45305
 [19,] 142.2364 53.42055
 [20,] 142.2358 53.40749
 [21,] 142.2447 53.38721
 [22,] 142.2533 53.38055
 [23,] 142.2747 53.36971
 [24,] 142.3516 53.35610
 [25,] 142.4641 53.38305
 [26,] 142.4753 53.38694
 [27,] 142.4864 53.39194
 [28,] 142.4955 53.39833
 [29,] 142.5025 53.40471
 [30,] 142.5092 53.41110
 [31,] 142.5208 53.42388
 [32,] 142.5530 53.46249
 [33,] 142.5577 53.46888
 [34,] 142.6803 53.50999
 [35,] 142.6819 53.52361
 [36,] 142.6764 53.54305
 [37,] 142.6722 53.54972
 [38,] 142.6139 53.56916
 [39,] 142.6030 53.57055
 [40,] 142.5591 53.56999
 [41,] 142.5478 53.56361
 [42,] 142.5411 53.55721
 [43,] 142.5364 53.55083
 [44,] 142.5294 53.54444
 [45,] 142.5183 53.53805
 [46,] 142.5119 53.54333
 [47,] 142.5056 53.55000
 [48,] 142.5016 53.56305
 [49,] 142.4950 53.60889
 [50,] 142.4936 53.62833
 [51,] 142.4927 53.65443
 [52,] 142.4950 53.66110
 [53,] 142.5042 53.66721
 [54,] 142.5153 53.67110
 [55,] 142.5375 53.67332
 [56,] 142.6367 53.67944
 [57,] 142.6478 53.67666
 [58,] 142.6583 53.66999
 [59,] 142.6669 53.66332
 [60,] 142.6750 53.64999
 [61,] 142.6769 53.64361
 [62,] 142.6830 53.63694
 [63,] 142.6938 53.63027
 [64,] 142.7047 53.62860
 [65,] 142.7158 53.62971
 [66,] 142.7269 53.63361
 [67,] 142.7361 53.63999
 [68,] 142.7750 53.67166
 [69,] 142.7983 53.69749
 [70,] 142.8008 53.70388
 [71,] 142.7994 53.71693
 [72,] 142.7944 53.74972
 [73,] 142.7858 53.79555
 [74,] 142.7747 53.83472
 [75,] 142.7705 53.84138
 [76,] 142.7594 53.84277
 [77,] 142.7389 53.82221
 [78,] 142.7322 53.82154
 [79,] 142.7254 53.81855
 [80,] 142.7140 53.80305
 [81,] 142.7110 53.79538
 [82,] 142.7092 53.78755
 [83,] 142.7089 53.77972
 [84,] 142.7064 53.76772
 [85,] 142.6891 53.73916
 [86,] 142.6772 53.71971
 [87,] 142.6703 53.71333
 [88,] 142.6614 53.70833
 [89,] 142.6500 53.70332
 [90,] 142.6164 53.69083
 [91,] 142.6055 53.69110
 [92,] 142.6036 53.69749
 [93,] 142.6111 53.71693
 [94,] 142.6678 53.80527
 [95,] 142.6907 53.84010
 [96,] 142.6952 53.84777
 [97,] 142.6969 53.85560
 [98,] 142.7216 53.92444
 [99,] 142.7197 53.93082
[100,] 142.7116 53.94415
[101,] 142.7052 53.95083
[102,] 142.6625 53.98416
[103,] 142.5964 54.03611
[104,] 142.5000 54.11194
[105,] 142.4847 54.12527
[106,] 142.4658 54.14500
[107,] 142.4594 54.15166
[108,] 142.3939 54.23750
[109,] 142.4019 54.26611
[110,] 142.4803 54.27388
[111,] 142.5269 54.24249
[112,] 142.5289 54.23611
[113,] 142.5352 54.23082
[114,] 142.5464 54.22916
[115,] 142.5686 54.22887
[116,] 142.5800 54.23388
[117,] 142.6394 54.26277
[118,] 142.6466 54.27583
[119,] 142.6519 54.28860
[120,] 142.6269 54.32555
[121,] 142.6805 54.41332
[122,] 142.6852 54.41972
[123,] 142.6966 54.42471
[124,] 142.7077 54.42471
[125,] 142.7191 54.42444
[126,] 142.7303 54.42305
[127,] 142.7411 54.41750
[128,] 142.7475 54.41082
[129,] 142.7536 54.39777
[130,] 142.7597 54.38472
[131,] 142.7617 54.37804
[132,] 142.7739 54.35833
[133,] 142.8133 54.29888
[134,] 142.8197 54.29222
[135,] 142.9136 54.21471
[136,] 143.0050 54.13750
[137,] 143.0114 54.13082
[138,] 143.0150 54.11749
[139,] 143.0086 54.08527
[140,] 142.9983 54.05916
[141,] 142.9911 54.04639
[142,] 142.9814 54.03361
[143,] 142.9602 54.01444
[144,] 142.9511 54.00805
[145,] 142.9369 53.99527
[146,] 142.9253 53.98249
[147,] 142.8786 53.89610
[148,] 142.8813 53.80804
[149,] 142.9016 53.77499
[150,] 142.9547 53.71860
[151,] 143.0114 53.66527
[152,] 143.1039 53.55499
[153,] 143.1247 53.50249
[154,] 143.1319 53.47610
[155,] 143.1100 53.40110
[156,] 143.0941 53.38972
[157,] 143.0872 53.38333
[158,] 143.0955 53.37666
[159,] 143.1064 53.37638
[160,] 143.1186 53.37804
[161,] 143.1297 53.38055
[162,] 143.1408 53.38527
[163,] 143.1500 53.39166
[164,] 143.1611 53.39666
[165,] 143.1722 53.39916
[166,] 143.1811 53.39888
[167,] 143.1991 53.37249
[168,] 143.2030 53.36583
[169,] 143.2263 53.32083
[170,] 143.2855 53.14999
[171,] 143.2892 53.13694
[172,] 143.2908 53.13027
[173,] 143.3291 52.91444
[174,] 143.3375 52.82916
[175,] 143.3375 52.73860
[176,] 143.3375 52.73360
[177,] 143.3369 52.71832
[178,] 143.3350 52.69249
[179,] 143.3258 52.59888
[180,] 143.3216 52.55721
[181,] 143.3169 52.53055
[182,] 143.3086 52.48777
[183,] 143.3064 52.47694
[184,] 143.3011 52.46055
[185,] 143.2919 52.44276
[186,] 143.2852 52.43111
[187,] 143.2542 52.39249
[188,] 143.2402 52.37666
[189,] 143.2305 52.36694
[190,] 143.2041 52.34471
[191,] 143.1950 52.34638
[192,] 143.1919 52.40971
[193,] 143.1958 52.42083
[194,] 143.2000 52.42694
[195,] 143.2136 52.44276
[196,] 143.2188 52.44721
[197,] 143.2316 52.45249
[198,] 143.2928 52.57916
[199,] 143.2941 52.58443
[200,] 143.2939 52.58943
[201,] 143.2852 52.59222
[202,] 143.2669 52.59471
[203,] 143.2580 52.59527
[204,] 143.2511 52.59361
[205,] 143.2477 52.58860
[206,] 143.1528 52.38166
[207,] 143.1650 52.32722
[208,] 143.1797 52.31583
[209,] 143.1814 52.31138
[210,] 143.1497 52.13110
[211,] 143.1316 52.07639
[212,] 143.1250 51.96055
[213,] 143.1344 51.92332
[214,] 143.1650 51.86500
[215,] 143.1750 51.85750
[216,] 143.1950 51.85278
[217,] 143.2119 51.85194
[218,] 143.2183 51.85471
[219,] 143.2219 51.87110
[220,] 143.2213 51.88110
[221,] 143.2266 51.88555
[222,] 143.2336 51.88750
[223,] 143.2380 51.88333
[224,] 143.2427 51.87444
[225,] 143.2969 51.77110
[226,] 143.3014 51.76221
[227,] 143.3150 51.72943
[228,] 143.3172 51.70471
[229,] 143.3127 51.70277
[230,] 143.3083 51.70694
[231,] 143.3025 51.71027
[232,] 143.2947 51.71249
[233,] 143.2883 51.70972
[234,] 143.2833 51.70527
[235,] 143.2647 51.68416
[236,] 143.2583 51.67222
[237,] 143.2350 51.61277
[238,] 143.2339 51.60750
[239,] 143.2194 51.52583
[240,] 143.2208 51.52138
[241,] 143.2286 51.50805
[242,] 143.2341 51.50444
[243,] 143.2413 51.50111
[244,] 143.3105 51.51250
[245,] 143.3350 51.55360
[246,] 143.3289 51.56750
[247,] 143.3258 51.57666
[248,] 143.3236 51.59138
[249,] 143.3250 51.60777
[250,] 143.3261 51.61305
[251,] 143.3352 51.62360
[252,] 143.3402 51.62804
[253,] 143.3572 51.63972
[254,] 143.3641 51.64166
[255,] 143.3708 51.64138
[256,] 143.3766 51.63277
[257,] 143.4500 51.49860
[258,] 143.4561 51.48472
[259,] 143.4591 51.47027
[260,] 143.4661 51.39555
[261,] 143.4688 51.36055
[262,] 143.4589 51.34860
[263,] 143.4530 51.35722
[264,] 143.4472 51.36082
[265,] 143.4280 51.36500
[266,] 143.4150 51.36055
[267,] 143.3819 51.34860
[268,] 143.3783 51.34471
[269,] 143.3827 51.34055
[270,] 143.4700 51.26777
[271,] 143.4958 51.29916
[272,] 143.4969 51.30471
[273,] 143.5031 51.30332
[274,] 143.5103 51.29500
[275,] 143.5191 51.27694
[276,] 143.5269 51.25861
[277,] 143.5341 51.23943
[278,] 143.5658 51.10722
[279,] 143.5705 51.07749
[280,] 143.5711 51.06221
[281,] 143.5886 50.99527
[282,] 143.6491 50.83388
[283,] 143.6600 50.80083
[284,] 143.6869 50.69554
[285,] 143.6936 50.65638
[286,] 143.7222 50.52499
[287,] 143.7691 50.36944
[288,] 143.7750 50.35055
[289,] 143.7919 50.30054
[290,] 143.7978 50.28694
[291,] 143.8080 50.26916
[292,] 143.8108 50.26472
[293,] 143.8280 50.24361
[294,] 143.8350 50.23527
[295,] 143.8463 50.22305
[296,] 143.8591 50.21111
[297,] 143.8747 50.19471
[298,] 143.8905 50.17332
[299,] 143.9413 50.10416
[300,] 143.9938 50.03111
[301,] 144.0025 50.01805
[302,] 144.0042 50.00833
[303,] 144.0641 49.84471
[304,] 144.2141 49.47110
[305,] 144.2222 49.41666
[306,] 144.2280 49.39777
[307,] 144.2758 49.26138
[308,] 144.3930 49.05222
[309,] 144.4036 49.03388
[310,] 144.4077 49.02999
[311,] 144.4175 49.02222
[312,] 144.4991 48.97221
[313,] 144.5183 48.96194
[314,] 144.5591 48.94221
[315,] 144.5728 48.93555
[316,] 144.6367 48.90138
[317,] 144.6650 48.88333
[318,] 144.6869 48.86860
[319,] 144.6908 48.86444
[320,] 144.6936 48.85999
[321,] 144.6950 48.85527
[322,] 144.7066 48.78055
[323,] 144.7052 48.77527
[324,] 144.7003 48.77083
[325,] 144.6917 48.75500
[326,] 144.6897 48.75200
[327,] 144.6890 48.74866
[328,] 144.6890 48.74249
[329,] 144.6909 48.73366
[330,] 144.6908 48.71333
[331,] 144.6972 48.69415
[332,] 144.7041 48.68055
[333,] 144.7097 48.67166
[334,] 144.7177 48.66360
[335,] 144.7233 48.65999
[336,] 144.7366 48.65332
[337,] 144.7461 48.65054
[338,] 144.7503 48.64666
[339,] 144.7516 48.64194
[340,] 144.7466 48.63721
[341,] 144.7394 48.63638
[342,] 144.7316 48.63638
[343,] 144.6900 48.64055
[344,] 144.6839 48.64305
[345,] 144.6783 48.64666
[346,] 144.6741 48.65582
[347,] 144.6531 48.72266
[348,] 144.6530 48.72882
[349,] 144.6520 48.74099
[350,] 144.6495 48.74949
[351,] 144.6470 48.75499
[352,] 144.6350 48.78999
[353,] 144.6155 48.82083
[354,] 144.5580 48.89277
[355,] 144.5375 48.91305
[356,] 144.4539 48.98472
[357,] 144.4413 48.99166
[358,] 144.3711 49.01361
[359,] 144.3641 49.01694
[360,] 144.3575 49.02027
[361,] 144.3463 49.02749
[362,] 144.2864 49.06777
[363,] 144.2780 49.07583
[364,] 144.2667 49.09361
[365,] 144.2597 49.10694
[366,] 144.2583 49.11194
[367,] 144.2542 49.12110
[368,] 144.2458 49.12916
[369,] 144.1528 49.19694
[370,] 144.1417 49.20416
[371,] 144.1022 49.22443
[372,] 144.0611 49.24416
[373,] 144.0203 49.25861
[374,] 143.9819 49.26888
[375,] 143.9455 49.27638
[376,] 143.9286 49.27777
[377,] 143.9130 49.27777
[378,] 143.8701 49.28219
[379,] 143.8361 49.28638
[380,] 143.7069 49.30249
[381,] 143.4655 49.35972
[382,] 143.4569 49.36749
[383,] 143.4291 49.38583
[384,] 143.4100 49.39583
[385,] 143.3919 49.39916
[386,] 143.3672 49.40054
[387,] 143.3513 49.40027
[388,] 143.2969 49.39861
[389,] 143.2825 49.39666
[390,] 143.2622 49.39083
[391,] 143.2561 49.38833
[392,] 143.2505 49.38472
[393,] 143.2461 49.37916
[394,] 143.2463 49.37416
[395,] 143.2480 49.36944
[396,] 143.2572 49.36111
[397,] 143.3122 49.31638
[398,] 143.3203 49.31361
[399,] 143.3438 49.31388
[400,] 143.3669 49.31527
[401,] 143.3966 49.31833
[402,] 143.4117 49.31944
[403,] 143.4347 49.32055
[404,] 143.4975 49.32138
[405,] 143.6011 49.32027
[406,] 143.6344 49.31805
[407,] 143.6619 49.31221
[408,] 143.6661 49.30833
[409,] 143.6600 49.30555
[410,] 143.6525 49.30444
[411,] 143.6055 49.30388
[412,] 143.5422 49.30388
[413,] 143.5005 49.30694
[414,] 143.4850 49.30666
[415,] 143.4261 49.29972
[416,] 143.3394 49.28694
[417,] 143.2903 49.27721
[418,] 143.2694 49.27249
[419,] 143.2628 49.27055
[420,] 143.1936 49.24610
[421,] 143.1433 49.22582
[422,] 143.1372 49.22305
[423,] 143.1255 49.21666
[424,] 143.0789 49.19110
[425,] 143.0736 49.18749
[426,] 143.0364 49.15943
[427,] 143.0314 49.15499
[428,] 143.0178 49.13972
[429,] 143.0133 49.13416
[430,] 142.9891 49.10139
[431,] 142.9841 49.08971
[432,] 142.9719 49.06027
[433,] 142.9683 49.04888
[434,] 142.9661 49.03805
[435,] 142.9650 49.02721
[436,] 142.9658 49.01194
[437,] 142.9719 48.99305
[438,] 142.9763 48.98388
[439,] 142.9822 48.97499
[440,] 142.9866 48.96082
[441,] 142.9900 48.94610
[442,] 142.9916 48.93638
[443,] 142.9925 48.92083
[444,] 142.9902 48.90999
[445,] 142.9783 48.89194
[446,] 142.9738 48.88666
[447,] 142.9280 48.81944
[448,] 142.8630 48.70972
[449,] 142.7811 48.55416
[450,] 142.7686 48.52972
[451,] 142.7600 48.51167
[452,] 142.7505 48.48804
[453,] 142.7469 48.47665
[454,] 142.6722 48.30444
[455,] 142.6197 48.20499
[456,] 142.6164 48.19332
[457,] 142.6127 48.18194
[458,] 142.5991 48.14555
[459,] 142.5686 48.07527
[460,] 142.5358 48.00805
[461,] 142.5347 48.00278
[462,] 142.5291 47.89666
[463,] 142.5300 47.87582
[464,] 142.5347 47.80416
[465,] 142.5367 47.78916
[466,] 142.5572 47.71666
[467,] 142.5680 47.68333
[468,] 142.5725 47.67416
[469,] 142.6039 47.62054
[470,] 142.6197 47.59388
[471,] 142.6311 47.57639
[472,] 142.7139 47.48499
[473,] 142.7797 47.42583
[474,] 142.7969 47.42055
[475,] 142.8291 47.40916
[476,] 142.8450 47.40332
[477,] 142.8600 47.39722
[478,] 142.8733 47.39055
[479,] 142.9005 47.37249
[480,] 142.9142 47.36082
[481,] 142.9264 47.34860
[482,] 143.0144 47.25417
[483,] 143.0200 47.24527
[484,] 143.0214 47.24055
[485,] 143.1058 46.91999
[486,] 143.1119 46.89055
[487,] 143.1069 46.84277
[488,] 143.0950 46.83721
[489,] 143.0902 46.83277
[490,] 143.0861 46.82722
[491,] 143.0836 46.82138
[492,] 143.0839 46.81610
[493,] 143.0883 46.80166
[494,] 143.1669 46.70916
[495,] 143.1722 46.70555
[496,] 143.1902 46.70139
[497,] 143.3436 46.68055
[498,] 143.3589 46.68082
[499,] 143.3716 46.68443
[500,] 143.3769 46.68804
[501,] 143.3867 46.69721
[502,] 143.3908 46.70277
[503,] 143.3919 46.70833
[504,] 143.3867 46.71721
[505,] 143.3688 46.73305
[506,] 143.3769 46.78638
[507,] 143.4319 46.83305
[508,] 143.4372 46.83665
[509,] 143.4433 46.83943
[510,] 143.4497 46.84138
[511,] 143.4577 46.84055
[512,] 143.4725 46.83416
[513,] 143.4805 46.82610
[514,] 143.4916 46.80860
[515,] 143.5219 46.71805
[516,] 143.5233 46.70805
[517,] 143.5236 46.70277
[518,] 143.5225 46.69721
[519,] 143.5150 46.68472
[520,] 143.5125 46.67860
[521,] 143.5114 46.67305
[522,] 143.5117 46.66805
[523,] 143.5150 46.64277
[524,] 143.5244 46.58221
[525,] 143.5486 46.49972
[526,] 143.5544 46.48055
[527,] 143.5786 46.40916
[528,] 143.6019 46.38361
[529,] 143.5875 46.35166
[530,] 143.5203 46.22694
[531,] 143.5164 46.22054
[532,] 143.5111 46.21693
[533,] 143.5005 46.20972
[534,] 143.4897 46.20222
[535,] 143.4803 46.19332
[536,] 143.4761 46.18777
[537,] 143.4688 46.16999
[538,] 143.4655 46.15332
[539,] 143.4658 46.14805
[540,] 143.4713 46.12888
[541,] 143.4747 46.10860
[542,] 143.4750 46.09833
[543,] 143.4738 46.09277
[544,] 143.4314 46.01944
[545,] 143.4253 46.01944
[546,] 143.4077 46.07749
[547,] 143.4075 46.08250
[548,] 143.4247 46.12860
[549,] 143.4280 46.18194
[550,] 143.4275 46.20277
[551,] 143.4230 46.21721
[552,] 143.4175 46.23138
[553,] 143.4119 46.24527
[554,] 143.3880 46.29610
[555,] 143.3589 46.35555
[556,] 143.3455 46.37833
[557,] 143.3397 46.39749
[558,] 143.3394 46.40804
[559,] 143.3452 46.46221
[560,] 143.3650 46.48666
[561,] 143.3708 46.48943
[562,] 143.3752 46.49500
[563,] 143.3861 46.51916
[564,] 143.3883 46.53027
[565,] 143.3867 46.53500
[566,] 143.3786 46.54833
[567,] 143.3677 46.55582
[568,] 143.3614 46.55888
[569,] 143.3522 46.56166
[570,] 143.3436 46.56305
[571,] 143.1691 46.58999
[572,] 143.1361 46.59388
[573,] 143.1291 46.59277
[574,] 143.1164 46.58888
[575,] 143.1105 46.58611
[576,] 143.1036 46.58499
[577,] 143.0825 46.58194
[578,] 143.0594 46.58250
[579,] 143.0097 46.58888
[580,] 142.8791 46.59721
[581,] 142.8047 46.59388
[582,] 142.7972 46.59388
[583,] 142.7805 46.59610
[584,] 142.7739 46.59943
[585,] 142.7697 46.60361
[586,] 142.7469 46.64916
[587,] 142.7339 46.68194
[588,] 142.7325 46.68694
[589,] 142.7272 46.71666
[590,] 142.7283 46.72221
[591,] 142.7274 46.73777
[592,] 142.7236 46.74194
[593,] 142.7175 46.74416
[594,] 142.7097 46.74416
[595,] 142.6003 46.71138
[596,] 142.5753 46.70277
[597,] 142.5264 46.68250
[598,] 142.4969 46.66833
[599,] 142.4869 46.65999
[600,] 142.4680 46.64166
[601,] 142.4214 46.58250
[602,] 142.2953 46.34083
[603,] 142.2500 46.19638
[604,] 142.2272 46.11250
[605,] 142.2000 46.02610
[606,] 142.1964 46.01971
[607,] 142.0963 45.89527
[608,] 142.0911 45.89138
[609,] 142.0855 45.88860
[610,] 142.0775 45.89138
[611,] 142.0505 45.91471
[612,] 142.0341 45.93082
[613,] 141.9291 46.03583
[614,] 141.9264 46.04028
[615,] 141.9250 46.04500
[616,] 141.9247 46.05027
[617,] 141.9255 46.05582
[618,] 141.9278 46.06194
[619,] 141.9350 46.07471
[620,] 141.9372 46.08055
[621,] 141.9383 46.08611
[622,] 141.9380 46.09138
[623,] 141.9000 46.26971
[624,] 141.8936 46.28889
[625,] 141.8878 46.30277
[626,] 141.8816 46.31667
[627,] 141.8522 46.38166
[628,] 141.8380 46.40721
[629,] 141.8308 46.42083
[630,] 141.8291 46.42555
[631,] 141.8272 46.43555
[632,] 141.8194 46.48582
[633,] 141.8152 46.53944
[634,] 141.8127 46.58611
[635,] 141.8136 46.59166
[636,] 141.8158 46.59777
[637,] 141.9753 46.89471
[638,] 141.9836 46.90582
[639,] 141.9913 46.91750
[640,] 142.0225 46.97638
[641,] 142.0308 46.99471
[642,] 142.0480 47.03666
[643,] 142.0503 47.04250
[644,] 142.0514 47.04805
[645,] 142.0555 47.07055
[646,] 142.0586 47.08721
[647,] 142.0594 47.12471
[648,] 142.0583 47.14527
[649,] 142.0550 47.16027
[650,] 142.0519 47.16972
[651,] 142.0411 47.20305
[652,] 142.0297 47.23221
[653,] 142.0180 47.25000
[654,] 142.0142 47.25388
[655,] 141.9936 47.26860
[656,] 141.9783 47.27999
[657,] 141.9702 47.28805
[658,] 141.9528 47.45750
[659,] 141.9511 47.48860
[660,] 141.9614 47.59138
[661,] 141.9647 47.60860
[662,] 142.0033 47.69666
[663,] 142.0816 47.83665
[664,] 142.0855 47.84305
[665,] 142.1028 47.86388
[666,] 142.1219 47.88221
[667,] 142.1333 47.88860
[668,] 142.1436 47.89694
[669,] 142.1580 47.91055
[670,] 142.1722 47.92444
[671,] 142.1766 47.92972
[672,] 142.1864 47.94833
[673,] 142.1886 47.95416
[674,] 142.1894 47.96500
[675,] 142.1889 47.97527
[676,] 142.1841 47.98943
[677,] 142.1789 48.01416
[678,] 142.1769 48.02416
[679,] 142.1733 48.04388
[680,] 142.1686 48.08416
[681,] 142.1619 48.16638
[682,] 142.1566 48.24332
[683,] 142.1514 48.26777
[684,] 142.1480 48.28249
[685,] 142.1464 48.28722
[686,] 142.1355 48.31554
[687,] 142.1311 48.32444
[688,] 142.1075 48.37054
[689,] 142.1003 48.38388
[690,] 142.0855 48.40582
[691,] 142.0755 48.41860
[692,] 142.0155 48.48972
[693,] 141.9358 48.58167
[694,] 141.9169 48.60750
[695,] 141.9083 48.62054
[696,] 141.8886 48.65638
[697,] 141.8750 48.68388
[698,] 141.8605 48.72638
[699,] 141.8524 48.75027
[700,] 141.8530 48.76083
[701,] 141.8569 48.76721
[702,] 141.8697 48.78333
[703,] 141.9128 48.82527
[704,] 141.9225 48.83443
[705,] 141.9475 48.84527
[706,] 141.9530 48.84888
[707,] 141.9625 48.85805
[708,] 141.9675 48.86999
[709,] 141.9963 48.94916
[710,] 142.0022 48.96638
[711,] 142.0278 49.04166
[712,] 142.0700 49.24222
[713,] 142.0669 49.25166
[714,] 142.0650 49.26167
[715,] 142.0641 49.27694
[716,] 142.0644 49.29778
[717,] 142.0647 49.31361
[718,] 142.0667 49.32972
[719,] 142.0686 49.34055
[720,] 142.0741 49.36305
[721,] 142.0791 49.37471
[722,] 142.0864 49.38721
[723,] 142.0969 49.40499
[724,] 142.1044 49.41750
[725,] 142.1188 49.45277
[726,] 142.1236 49.46444
[727,] 142.1353 49.52499
[728,] 142.1405 49.55249
[729,] 142.1511 49.63333
[730,] 142.1605 49.78638
[731,] 142.1591 49.81194
[732,] 142.1555 49.82639
[733,] 142.1522 49.83582
[734,] 142.1392 49.85860
[735,] 142.1272 49.88110
[736,] 142.1263 49.89111
[737,] 142.1386 49.94860
[738,] 142.1528 50.00527
[739,] 142.1739 50.09415
[740,] 142.1508 50.33167
[741,] 142.1472 50.35139
[742,] 142.1372 50.37943
[743,] 142.1324 50.38860
[744,] 142.1297 50.39277
[745,] 142.1127 50.40916
[746,] 142.1097 50.41360
[747,] 142.0566 50.49694
[748,] 142.0489 50.51028
[749,] 142.0425 50.52888
[750,] 142.0422 50.53416
[751,] 142.0441 50.55000
[752,] 142.0511 50.59833
[753,] 142.0519 50.60388
[754,] 142.0950 50.81305
[755,] 142.1252 50.88638
[756,] 142.1342 50.89722
[757,] 142.1441 50.90610
[758,] 142.1547 50.91415
[759,] 142.1716 50.92500
[760,] 142.1825 50.93305
[761,] 142.2014 50.95277
[762,] 142.2191 50.97416
[763,] 142.2316 50.99833
[764,] 142.2366 51.01009
[765,] 142.2488 51.03916
[766,] 142.2550 51.05610
[767,] 142.2633 51.07916
[768,] 142.2678 51.10083
[769,] 142.2678 51.10805
[770,] 142.2672 51.12027
[771,] 142.2608 51.13916
[772,] 142.2561 51.14805
[773,] 142.2514 51.15694
[774,] 142.2380 51.17388
[775,] 142.2305 51.18221
[776,] 142.0852 51.39833
[777,] 142.0805 51.40749
[778,] 142.0772 51.41666
[779,] 142.0811 51.42305
[780,] 142.0916 51.42888
[781,] 142.0966 51.43333
[782,] 142.0977 51.43888
[783,] 142.0944 51.44833
[784,] 142.0897 51.45721
[785,] 142.0791 51.46971
[786,] 142.0688 51.47721
[787,] 142.0052 51.51611
[788,] 141.9233 51.57055
[789,] 141.7972 51.67749
[790,] 141.8047 51.71749
[791,] 141.8111 51.72027
[792,] 141.8211 51.72916
[793,] 141.8250 51.73527
[794,] 141.8208 51.78027
[795,] 141.8175 51.78972
[796,] 141.7772 51.82471
[797,] 141.7597 51.83527
[798,] 141.6480 51.88666
[799,] 141.6400 52.07972
[800,] 141.6414 52.08582
[801,] 141.6439 52.09166
[802,] 141.6478 52.09777
[803,] 141.6522 52.10305
[804,] 141.6778 52.12555
[805,] 141.6866 52.13611
[806,] 141.6930 52.14805
[807,] 141.6950 52.15888
[808,] 141.6936 52.17916
[809,] 141.6686 52.25916
[810,] 141.6400 52.31110
[811,] 141.6380 52.31583
[812,] 141.6519 52.36555
[813,] 141.6569 52.37721
[814,] 141.6608 52.38333
[815,] 141.6658 52.38777
[816,] 141.6772 52.39500
[817,] 141.7030 52.40665
[818,] 141.7433 52.43194
[819,] 141.7536 52.44083
[820,] 141.7683 52.45527
[821,] 141.7908 52.48166
[822,] 141.8377 52.57805
[823,] 141.8389 52.58360
[824,] 141.8497 52.71305
[825,] 141.8586 52.85139
[826,] 141.8911 52.93555
[827,] 141.9219 53.00388
[828,] 141.9253 53.01999
[829,] 141.9247 53.02499
[830,] 141.9172 53.05332
[831,] 141.9122 53.06721
[832,] 141.8933 53.09277
[833,] 141.8669 53.12138
[834,] 141.8516 53.13750
[835,] 141.8425 53.14527



Slot "plotOrder":
[1] 1

Slot "labpt":
[1] 142.71208  50.33426

Slot "ID":
[1] "0"

Slot "area":
[1] 9.533439



Slot "plotOrder":
[1] 1

Slot "bbox":
       min       max
x 141.6380 144.75165
y  45.8886  54.42471

Slot "proj4string":
CRS arguments:
 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
In [31]:
bbox<-shape_rgdal@bbox
In [32]:
as.numeric(bbox)
  1. 141.638031005859
  2. 45.8886032104492
  3. 144.751647949219
  4. 54.4247131347656

Rectangular area including contour of the shapefile is stored in bbox slot of the shape_rgdal S4-object. So, we can easily extract bounding box coordinates:

In [33]:
lonl<-as.numeric(bbox)[1]
lonu<-as.numeric(bbox)[3]
latl<-as.numeric(bbox)[2]
latu<-as.numeric(bbox)[4]

Further, let us form a search url and make a search request.

In [34]:
search_parameters_sakhalin <- c('lonl', lonl, 'lonu', lonu, 'latl', latl, 'latu', latu)
In [35]:
search_url_sakhalin <- paste(http_api_base_url, paste(search_parameters_sakhalin[c(TRUE, FALSE)], search_parameters_sakhalin[c(FALSE, TRUE)], sep='=', collapse='&'), sep='')

For the sake of the trust, explore the url:

In [36]:
search_url_sakhalin
'http://botsad.ru/hitem/json/?lonl=141.638031005859&lonu=144.751647949219&latl=45.8886032104492&latu=54.4247131347656'
In [37]:
sakhalin_data <- fromJSON(search_url_sakhalin)

Now we can explore how much records belong to the rectangular area including the contour of Sakhalin Island.

In [38]:
dim(sakhalin_data$data)
  1. 667
  2. 42
In [39]:
number_in_rectangle <- dim(sakhalin_data$data)[1]
In [40]:
sprintf("Therefore, the number of records belonging to the rectangular area: %d", number_in_rectangle)
'Therefore, the number of records belonging to the rectangular area: 667'

Additional filtration allows to exclude points outside the contour of Sakhalin Island. To make such filtration in R, it is convenient to use the sp package.

In [41]:
library(sp)
In [42]:
sakhalin_nonfiltered <- sakhalin_data$data

We need to transform original dataset sakhalin_nonfiltered into an object of spatially distributed data (exactly, R's S4 object from the sp package):

In [43]:
coordinates(sakhalin_nonfiltered) <- cbind(sakhalin_nonfiltered$longitude , sakhalin_nonfiltered$latitude)
In [44]:
sakhalin_nonfiltered@proj4string <- CRS(proj4string(shape_rgdal))

Due to the amazing syntax of the sp package, the filtering is performed by the only one line of the code:

In [45]:
sakhalin_filtered<-sakhalin_nonfiltered[shape_rgdal,]
In [46]:
dim(sakhalin_filtered)
  1. 632
  2. 42
In [47]:
number_in_sakhalin <- dim(sakhalin_filtered)[1]
In [48]:
sprintf('The number of filtered records: %d', number_in_rectangle - number_in_sakhalin)
'The number of filtered records: 35'

Attentive user could be surprised here: the rectangular area doesn't include any land, but only Sakhalin Island; why so many records were filtered out? The cause of that is quite simple. Such error-like phenomenon occurs because the records distributed on the seashore could be treated as non-belonging to the Sakhalin contour. That isn't a real error, just a result of errors in the contour definition/description and herbarium records positioning.

In [49]:
sprintf('Document execution date: %s', Sys.Date())
'Document execution date: 2017-12-19'

Author: Dmitry E. Kislov

E-mail: [email protected]