Extracting sensors with API using lat-lon box outputs the same sensors no matter the coordinates

@asmarcheva, thank you for the detail in your post and including a code snippet.

It looks like your code is sending requests using xmin and xmax as latitude values and ymin and ymax as longitude values. Swapping xmin with ymin and swapping xmax with ymax will likely use the correct bounding box without any other code changes.

I confirmed this by examining the logs for your API account. You can view these logs for your requests by logging in to https://develop.purpleair.com and clicking “Logs” at the top. The table below shows how the parameters were being mixed up for Clifton, Ohio:

Parameter Bounding Box for Clifton Supplied in Your Requests
nwlat 39.31206 -84.8203
nwlng -84.8203 39.02153
selat 39.02153 -84.25633
selng -84.25633 39.31206

Why Both Bounding Boxes Received the Same Set of Sensors

Since latitude and longitude were mixed up, both of the bounding boxes you created were over Antarctica. Sensors registered without a location are placed near Antarctica (more specifically around a latitude of -70), which we refer to as “No Mans Land”.

Requesting a bounding box from the API that goes below a latitude of -70 will result in sensors from No Man’s Land being included in the response. Since these sensors have no location set, requesting the fields latitude and longitude from them will return values of null.

Both mixed-up bounding boxes sent in your requests were below -70, which is why they both returned these sensors.

3 Likes