# Data by county?

**URL:** <https://forum.sensor.community/t/data-by-county/2533>\
**Category:** Uncategorized\
**Created:** [January 9, 2024, 12:25pm UTC](https://forum.sensor.community/t/data-by-county/2533 "2024-01-09T12:25:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niamh](https://forum.sensor.community/user_avatar/forum.sensor.community/niamh/32/1610_2.png) [@Niamh](https://forum.sensor.community/u/Niamh)\
**Post date:** [January 9, 2024, 12:25pm UTC](https://forum.sensor.community/t/data-by-county/2533/1 "2024-01-09T12:25:24Z")

</div>

Hi,

Does anyone know if there is a way to download data by county? I am currently hoping to download all the data for each monitor within Sheffield and was wondering what the best way is to do this? I was hoping to find the data classed either by county or even sensor name instead of by date as I would like to download all the data (so all the dates) for each sensor in Sheffield.

Hope that makes sense

---

<div class="post-metadata">

**Author:** ![ricki-z](https://forum.sensor.community/user_avatar/forum.sensor.community/ricki-z/32/215_2.png) [@ricki-z](https://forum.sensor.community/u/ricki-z)\
**Post date:** [January 9, 2024, 11:28pm UTC](https://forum.sensor.community/t/data-by-county/2533/2 "2024-01-09T23:28:25Z")

</div>

Hello @Niamh, there are only files with the data of all sensors per month and sensor type (i.e. all SDS011) worldwide. You can find them at [https://archive.sensor.community/csv\_per\_month/](https://archive.sensor.community/csv_per_month/)

---

<div class="post-metadata">

**Author:** ![pjg](https://forum.sensor.community/user_avatar/forum.sensor.community/pjg/32/194_2.png) [@pjg](https://forum.sensor.community/u/pjg)\
**Post date:** [January 10, 2024, 7:22pm UTC](https://forum.sensor.community/t/data-by-county/2533/3 "2024-01-10T19:22:49Z")

</div>

You can intersect the api data in a GIS software like QGiS to get the list of sensors in Sheffield.  
Then you can use some script to download the data for these sensors. Examples in this forum.

> [@R-Script or tips to download and use sensor data](https://forum.sensor.community/t/r-script-or-tips-to-download-and-use-sensor-data/426/4):
>
> I would do: load the current API data in order to get the list of all the sensors as json: [https://data.sensor.community/static/v1/data.json](https://data.sensor.community/static/v1/data.json) import the data in QGIS: [Download QGIS](https://www.qgis.org/en/site/forusers/download.html) get a shapefile of Belgium and import it in QGIS use the intersection algorithm in QGIS in order to get the sensor IDs in Belgium write a simple script in python to download in the archives according to IDs and dates : import requests #Mettre les ID des capteurs dans le tableau séparées par des virgules…

---

<div class="post-metadata">

**Author:** ![Niamh](https://forum.sensor.community/user_avatar/forum.sensor.community/niamh/32/1610_2.png) [@Niamh](https://forum.sensor.community/u/Niamh)\
**Post date:** [January 15, 2024, 12:13pm UTC](https://forum.sensor.community/t/data-by-county/2533/4 "2024-01-15T12:13:01Z")

</div>

Thank you for your reply. I am new to this so not sure how to work with the json data as I’ve never seen this before. How do I get the list of all the sensors I need using json?

Also is there a list somewhere for all the sensors in each region?

Many thanks again

---

<div class="post-metadata">

**Author:** ![pjg](https://forum.sensor.community/user_avatar/forum.sensor.community/pjg/32/194_2.png) [@pjg](https://forum.sensor.community/u/pjg)\
**Post date:** [January 20, 2024, 12:10pm UTC](https://forum.sensor.community/t/data-by-county/2533/5 "2024-01-20T12:10:28Z")

</div>

I check something and give you tipps soon.

---

<div class="post-metadata">

**Author:** ![pjg](https://forum.sensor.community/user_avatar/forum.sensor.community/pjg/32/194_2.png) [@pjg](https://forum.sensor.community/u/pjg)\
**Post date:** [January 20, 2024, 5:56pm UTC](https://forum.sensor.community/t/data-by-county/2533/6 "2024-01-20T17:56:15Z")

</div>

I explain step by step.

**1-Get the last data as json**

[https://data.sensor.community/static/v2/data.dust.min.json](https://data.sensor.community/static/v2/data.dust.min.json)

**2-Convert json to csv**

> **[JSON To CSV Converter](https://www.convertcsv.com/json-to-csv.htm)**
>
> Convert JSON to CSV/Excel

**3-Open the csv in Excel**

Keep the column:  
l **ocation/latitude location/longitude location/country location/indoor sensor/id sensor/sensor\_type/name**

Save as csv.

**4-Open QGIS**

Import the data.

 ![Screen Shot 2024-01-20 at 18.53.27](https://forum.sensor.community/uploads/default/original/2X/3/3fba4b255eecff4689da6dcbc647c493942fde37.png)

 ![Screen Shot 2024-01-20 at 18.54.05](https://forum.sensor.community/uploads/default/original/2X/9/9893d3c8e4701084bf6d972c3e876754f8e60023.png)

 ![Screen Shot 2024-01-20 at 18.54.41](https://forum.sensor.community/uploads/default/original/2X/d/d1ed8300c8cbc8bbe19f6b0859de919bce399d61.png)

---

<div class="post-metadata">

**Author:** ![pjg](https://forum.sensor.community/user_avatar/forum.sensor.community/pjg/32/194_2.png) [@pjg](https://forum.sensor.community/u/pjg)\
**Post date:** [January 20, 2024, 6:15pm UTC](https://forum.sensor.community/t/data-by-county/2533/7 "2024-01-20T18:15:14Z")

</div>

**5-Find a shapefile of Sheffield**

> **[City Boundary](https://sheffield-city-council-open-data-sheffieldcc.hub.arcgis.com/datasets/4cdfd020c6f54581a3065c734535adab_11/explore)**
>
> Administrative boundary of Sheffield

 ![Screen Shot 2024-01-20 at 19.14.51](https://forum.sensor.community/uploads/default/original/2X/a/abd3b42aaad357fc1dcf9ab5e18b82e792249736.png)

---

<div class="post-metadata">

**Author:** ![pjg](https://forum.sensor.community/user_avatar/forum.sensor.community/pjg/32/194_2.png) [@pjg](https://forum.sensor.community/u/pjg)\
**Post date:** [January 20, 2024, 6:18pm UTC](https://forum.sensor.community/t/data-by-county/2533/8 "2024-01-20T18:18:08Z")

</div>

**6-Intersect**

 ![Screen Shot 2024-01-20 at 19.17.03](https://forum.sensor.community/uploads/default/original/2X/e/e057671ac97cf8f8ee71c7ebac1f024fae0de09f.png)

You know has the list of sensors in Sheffield

 ![Screen Shot 2024-01-20 at 19.16.41](https://forum.sensor.community/uploads/default/original/2X/f/f7a05652c0bf50dfd9425d3219da5f4680c27fbf.png)

---

<div class="post-metadata">

**Author:** ![pjg](https://forum.sensor.community/user_avatar/forum.sensor.community/pjg/32/194_2.png) [@pjg](https://forum.sensor.community/u/pjg)\
**Post date:** [January 20, 2024, 6:27pm UTC](https://forum.sensor.community/t/data-by-county/2533/9 "2024-01-20T18:27:40Z")

</div>

21103  
21258  
21987  
22019  
24153  
24409  
25611  
28016  
28852  
29078  
29602  
31722  
41897  
54561  
55619  
56688  
60245  
61081  
62183  
62532  
65735  
67997  
68953  
68956  
69003  
69752  
70477  
7189  
73919  
74377  
74857  
74858  
75671  
77752  
77754  
77758  
7776  
77767  
78099  
83024

---

<div class="post-metadata">

**Author:** ![pjg](https://forum.sensor.community/user_avatar/forum.sensor.community/pjg/32/194_2.png) [@pjg](https://forum.sensor.community/u/pjg)\
**Post date:** [January 20, 2024, 6:28pm UTC](https://forum.sensor.community/t/data-by-county/2533/10 "2024-01-20T18:28:41Z")

</div>

Now you can download from the archive with the instructions in this forum.

---

<div class="post-metadata">

**Author:** ![Niamh](https://forum.sensor.community/user_avatar/forum.sensor.community/niamh/32/1610_2.png) [@Niamh](https://forum.sensor.community/u/Niamh)\
**Post date:** [January 24, 2024, 2:21pm UTC](https://forum.sensor.community/t/data-by-county/2533/11 "2024-01-24T14:21:09Z")

</div>

Hi, thank you so much for this step by step guide, I really appreciate it, I will give it a go. Once I have done the above, how would I use that information to download only the data for the specific sites? As I already have a list of the Sheffield sites but wasnt sure how to just download only their specific data

---

<div class="post-metadata">

**Author:** ![pjg](https://forum.sensor.community/user_avatar/forum.sensor.community/pjg/32/194_2.png) [@pjg](https://forum.sensor.community/u/pjg)\
**Post date:** [January 25, 2024, 6:08pm UTC](https://forum.sensor.community/t/data-by-county/2533/12 "2024-01-25T18:08:03Z")

</div>

```auto
import requests
import time
#Mettre les ID des capteurs dans le tableau séparées par des virgules
#SDS11 only here
sensor_id = ["77136","77144","77445","33624","61705"]
#Mettre les dates dans le tableau au format 'YYYY-MM-DD' séparées par des virgules
dates = ["2022-01-01","2022-01-02","2022-01-03","2022-01-04","2022-01-05","2022-01-06","2022-01-07","2022-01-08","2022-01-09","2022-01-10","2022-01-11","2022-01-12","2022-01-13","2022-01-14","2022-01-15","2022-01-16","2022-01-17","2022-01-18","2022-01-19","2022-01-20","2022-01-21","2022-01-22"]

url_deb = 'http://archive.sensor.community/2022/'

for n1 in range(0,len(dates)):

    date = dates[n1]
    url_ok = url_deb + date
    print(url_ok)
    r1 = requests.get(url_ok)
    source_code = r1.text
    data_to_write ='sensor_id;sensor_type;location;lat;lon;timestamp;P1;durP1;ratioP1;P2;durP2;ratioP2\n'

    for n2 in range(0,len(sensor_id)):

        test = 'sensor_'+sensor_id[n2]+'.csv'
        
        if test in source_code:

            split1 = source_code.split(test)[0]
            split2 = split1.split('<a href="')[-1]
            url_fin = url_ok + '/' + split2 + test
            print(url_fin)
            r2 = requests.get(url_fin)
            data = r2.text
            split = data.splitlines(True)
            #print(split)
            
            for n3 in range(1,len(split)):
                data_to_write += split[n3]
        
        time.sleep(0.1)
            

    f = open("/Users/PJ/Desktop/gressent/scrap_file_"+date+".csv", "a")
    f.write(data_to_write)
    f.close()

```

Here the python script for SDS011

---

<div class="post-metadata">

**Author:** ![Niamh](https://forum.sensor.community/user_avatar/forum.sensor.community/niamh/32/1610_2.png) [@Niamh](https://forum.sensor.community/u/Niamh)\
**Post date:** [January 29, 2024, 2:45pm UTC](https://forum.sensor.community/t/data-by-county/2533/13 "2024-01-29T14:45:45Z")

</div>

Thank you for this, I really appreciate the help
