Open asmarcheva opened 3 days ago
Hi, thanks for the note. Could you provide a minimal, reproducible example that illustrates the unexpected result? That will help best identify the problem so we can decide how to fix it.
These give the same sensors output. The first is from Ithaca, NY, the second is the example from the documentation
get_sensors_data(st_bbox(
c("xmin" = -76.52, "ymin" = 42.41,
"xmax" = -76.47, "ymax" = 42.46),
crs = 4326) , fields = c("name"), location_type = "outside")
get_sensors_data(st_bbox(c("xmin" = -84.82030, "ymin" = 39.02153,
"xmax" = -84.25633, "ymax" = 39.31206),
crs = 4326),
fields = c("name"), location_type = "outside")
Thanks, could you make it so that I could run the code and get the same result? For example are you loading the sf library first?
Also, could you show the output that you get so I can make sure that I can reproduce the issue?
Yes, sorry I have never submitted an issue before :)
if (!require("pacman")) install.packages("pacman")
pacman::p_load(PurpleAir, sf)
get_sensors_data(st_bbox(
c("xmin" = -76.52, "ymin" = 42.41,
"xmax" = -76.47, "ymax" = 42.46),
crs = 4326) , fields = c("name"), location_type = "outside")
get_sensors_data(st_bbox(c("xmin" = -84.82030, "ymin" = 39.02153,
"xmax" = -84.25633, "ymax" = 39.31206),
crs = 4326),
fields = c("name"), location_type = "outside")
Output (for both):
# A tibble: 36 × 2
sensor_index name
<int> <chr>
1 30561 lineblock_outside2
2 35107 807D3A615CCF
3 35109 807D3A615D8E
4 35121 807D3A615C42
5 35137 807D3A615C77
6 36325 807d3a616167
7 36681 68c63a8e59a
8 42623 KMI_041
9 49213 807D3A615D1E
10 56287 PSPS_12
# ℹ 26 more rows
# ℹ Use `print(n = ...)` to see more rows
Thanks, that is indeed unexpected behavior. I tried to recreate the call using the PurpleAir API documentation tool, I can make a request using these parameters and my API key:
with this response
200 success
{
"api_version" : "V1.0.14-0.0.58",
"time_stamp" : 1727908305,
"data_time_stamp" : 1727908252,
"max_age" : 604800,
"firmware_default_version" : "7.02",
"fields" : ["sensor_index","name"],
"data" : [
[30303,"\uC544\uAC00\uD398_\uC2E4\uB0B4"],
[30561,"lineblock_outside2"],
[30571,"amlok_inside"],
[35107,"807D3A615CCF"],
[35109,"807D3A615D8E"],
[35121,"807D3A615C42"],
[35137,"807D3A615C77"],
[36325,"807d3a616167"],
[36681,"68c63a8e59a"],
[42623,"KMI_041"],
[49213,"807D3A615D1E"],
[56287,"PSPS_12"],
[65359,"Ben Lomond"],
[73997,"Home"],
[75973,"Living Room"],
[76099,"Los ninos"],
[88787,"INDOOR: Fairmount Hill"],
[98265,"PSPS_8"],
[108194,"FCF"],
[111149,"007"],
[111504,"1810 6th street Berkeley"],
[111642,"Jay Road"],
[112992,"10:52:1C:44:17:A1"],
[119867,"Island of Misfit Toys"],
[121211,"Westwood hill"],
[121917,"City of Livermore"],
[129909,"Wiley Ct"],
[130921,"Inside Casa"],
[162115,"Chardonnay Ct"],
[180103,"Queens College"],
[208443,"A06"],
[208445,"015"],
[208451,"008"],
[208449,"010"],
[208453,"004"],
[208457,"003"],
[234933,"Central District"],
[235417,"4418 elser"],
[243323,"016"],
[243321,"013"],
[243327,"A04"],
[243325,"A01"],
[243331,"A15"],
[243329,"A11"]
]
}
Running the same example in the R package gives the same results:
# A tibble: 44 × 2
sensor_index name
<int> <chr>
1 30303 아가페_실내
2 30561 lineblock_outside2
3 30571 amlok_inside
4 35107 807D3A615CCF
5 35109 807D3A615D8E
6 35121 807D3A615C42
7 35137 807D3A615C77
8 36325 807d3a616167
9 36681 68c63a8e59a
10 42623 KMI_041
11 49213 807D3A615D1E
12 56287 PSPS_12
13 65359 Ben Lomond
14 73997 Home
15 75973 Living Room
16 76099 Los ninos
17 88787 INDOOR: Fairmount Hill
18 98265 PSPS_8
19 108194 FCF
20 111149 007
21 111504 1810 6th street Berkeley
22 111642 Jay Road
23 112992 10:52:1C:44:17:A1
24 119867 Island of Misfit Toys
25 121211 Westwood hill
26 121917 City of Livermore
27 129909 Wiley Ct
28 130921 Inside Casa
29 162115 Chardonnay Ct
30 180103 Queens College
31 208443 A06
32 208445 015
33 208451 008
34 208449 010
35 208453 004
36 208457 003
37 234933 Central District
38 235417 4418 elser
39 243323 016
40 243321 013
41 243327 A04
42 243325 A01
43 243331 A15
44 243329 A11
These are not the sensors I expect to see in the bbox and are incorrect, but the R function does return the same answer that the PurpleAir API testing tool does.
So it seems to be an issue with the PurpleAir API. I would suggest opening a thread for support with them. Please let us know what you find out, we would love to make note of it here!
Thanks for checking this; I submitted a post to the PurpleAir forum and I'll let you know what they say
Every st_bbox we have used in the get_sensors_data function returns the same sensors