<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Evolvo Ergo Sum</title>
<link>https://www.giulianocolosimo.com/blog.html</link>
<atom:link href="https://www.giulianocolosimo.com/blog.xml" rel="self" type="application/rss+xml"/>
<description>Ecology, Evolution with a sprinkle of Technology</description>
<generator>quarto-1.8.21</generator>
<lastBuildDate>Mon, 24 Mar 2025 23:00:00 GMT</lastBuildDate>
<item>
  <title>Smuggling of rare Galapagos Iguanas!</title>
  <dc:creator>Giuliano Colosimo</dc:creator>
  <link>https://www.giulianocolosimo.com/posts/citespub/</link>
  <description><![CDATA[ 





<p>The latest paper titled <em>Trafficking of Galápagos iguanas as an example of a global problem: CITES permits, laundering and the role of transit countries in Europe and Africa</em> is finally out. Huge effort, involving 20 colleagues and authors and experts on the matter.</p>
<p>The paper’s highlights:</p>
<ul>
<li>We highlight the smuggling of Galápagos iguanas in Africa, Asia, Europe, and the Pacific region.</li>
<li>Wild caught Galapagos iguanas are laundered into international trade declared as captive-bred. The offspring of such animals receive CITES permits in violation of CITES regulations.</li>
<li>Since 1975 all four iguana species have been listed on Appendix II of CITES.</li>
<li>We notice inaccuracies documented in the CITES trade database.</li>
<li>We urge CITES Parties to transfer all four species of Galápagos iguanas from CITES Appendix II to Appendix I.</li>
</ul>
<p>To read the full manuscript use <a href="https://doi.org/10.1016/j.biocon.2025.111104">this link</a> or the link in the reference section.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.giulianocolosimo.com/posts/citespub/map.jpg" class="img-fluid figure-img"></p>
<figcaption>Map of global trade in live Galapagos iguanas, as recorded in the CITES trade database <span class="citation" data-cites="Auliya2025">(After Auliya <em>et al.</em>, 2025)</span></figcaption>
</figure>
</div>




<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-Auliya2025" class="csl-entry">
Auliya, M., Nijman, V., Altherr, S., Aguilera, W.T., Ariano-Sanchez, D., Cantu, J.C., <em>et al.</em> 2025. <a href="https://doi.org/10.1016/j.biocon.2025.111104">Trafficking of galapagos iguanas as an example of a global problem: CITES permits, laundering and the role of transit countries in europe and africa</a>. <em>Biological Conservation</em>, <strong>305</strong>: 111104.
</div>
</div></section></div> ]]></description>
  <category>Publications</category>
  <guid>https://www.giulianocolosimo.com/posts/citespub/</guid>
  <pubDate>Mon, 24 Mar 2025 23:00:00 GMT</pubDate>
  <media:content url="https://www.giulianocolosimo.com/posts/citespub/map.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>New publications in early 2024!</title>
  <dc:creator>Giuliano Colosimo</dc:creator>
  <link>https://www.giulianocolosimo.com/posts/newpubs/</link>
  <description><![CDATA[ 





<p>Early in 2024 my colleagues and I had two manuscript published. The first one was published in <a href="https://conbio.onlinelibrary.wiley.com/doi/10.1111/csp2.13108">Conservation Science and Practice</a>, while the second was published in <a href="https://peerj.com/articles/17171/?td=bl">PeerJ</a>.</p>



 ]]></description>
  <category>Publications</category>
  <guid>https://www.giulianocolosimo.com/posts/newpubs/</guid>
  <pubDate>Thu, 02 May 2024 22:00:00 GMT</pubDate>
  <media:content url="https://www.giulianocolosimo.com/posts/newpubs/pinkpoptrend.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Translocation of Cyclura carinata from Little Water Cay to Grouper Cay.</title>
  <dc:creator>Giuliano Colosimo</dc:creator>
  <link>https://www.giulianocolosimo.com/posts/translocation/</link>
  <description><![CDATA[ 





<p>This summer, in the midst of the heat wave of late July and early August, we performed a translocation of <em>Cyclura carinata</em> individuals, the Turks and Caicos Rock Iguana, from Little Water Cay to Grouper Cay! Keep reading if you want to know more about this project and how it came about.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.giulianocolosimo.com/posts/translocation/cycar.png" class="img-fluid figure-img"></p>
<figcaption>A young <em>Cyclura carinata</em> individual. (Photo credits: G. Colosimo)</figcaption>
</figure>
</div>
<p><em>Cyclura carinata</em> is endemic to the Turks and Caicos Islands (TCI), a small and beautiful archipelago located north of Hispaniola Island (Haiti and Dominican Republic), in the Caribbean Sea. A species is defined endemic when it is native to a specific region and when it naturally can be found only in that particular area. Turks and Caicos Rock Iguanas is, in fact, native to the TCI and can only be found in this archipelago. The only exception is represented by a small population of TCI Rock Iguanas found on Booby Cay, The Bahamas. Genetic studies have recently demonstrated that the Booby Cay population is the outcome of a past introduction event <span class="citation" data-cites="Welch2017">(Welch <em>et al.</em>, 2017)</span>. Once occupying almost every single island in the TCI, the distribution range of <em>C carinata</em> dramatically decreased and they are considered extirpated from ca. 95% of their former range <span class="citation" data-cites="Gerber2007">(Gerber, 2007)</span>.</p>
<div class="cell">
<div class="cell-output-display">
<div class="leaflet html-widget html-fill-item" id="htmlwidget-4ccef82ec9d38d3e0c59" style="width:100%;height:464px;"></div>
<script type="application/json" data-for="htmlwidget-4ccef82ec9d38d3e0c59">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>,  <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]},{"method":"addMarkers","args":[21.8347,-72.1497,null,null,null,{"interactive":true,"draggable":false,"keyboard":true,"title":"","alt":"","zIndexOffset":0,"opacity":1,"riseOnHover":false,"riseOffset":250},"Little Water Cay, the source population",null,null,null,null,{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null]},{"method":"addMarkers","args":[21.8826,-72.0776,null,null,null,{"interactive":true,"draggable":false,"keyboard":true,"title":"","alt":"","zIndexOffset":0,"opacity":1,"riseOnHover":false,"riseOffset":250},"Grouper Cay, the site selected for translocation",null,null,null,null,{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null]}],"limits":{"lat":[21.8347,21.8826],"lng":[-72.1497,-72.0776]}},"evals":[],"jsHooks":[]}</script>
<p>An interactive map showing the Turks and Caicos Archipelago and the relative position of source and recipient sites used for the translocation.</p>
</div>
</div>
<p>The progressive reduction of their range, largely due to the intense development and construction activity on many islands, and the presence of introduced feral mammals (cats, dogs, rats, donkeys, pigs), caused, in 2004, the listing of this species as Critically Endangered (CR) in the International Union for the Conservation of Nature (IUCN) Red-List of Threatened Species <span class="citation" data-cites="Gerber2004a">(Gerber, 2004)</span>. This means that there is a concrete risk of extinction if no management actions are pursued.</p>
<p>A group of international researchers and volunteers, collaborating with local institutions like the Department of Environment and Coastal Resources (DECR) and the Turks and Caicos National Trust (TCINT), has been working for many years to ensure that this species could persist and thrive in its natural habitat. Thanks to their work, the implementation of different conservation strategies, and the involvement of local communities, the species has recently been down-listed from CR to Endangered (EN) in the IUCN Red-List of Threatened Species <span class="citation" data-cites="Gerber2020">(Gerber <em>et al.</em>, 2020)</span>. Although this represents very good news, it does not mean that conservation efforts can come to a stop. On the contrary, as the species persistence is still challenged by new development and the presence of introduced feral mammals, the level of guard and attention should not dim.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.giulianocolosimo.com/posts/translocation/cychead.png" class="img-fluid figure-img"></p>
<figcaption>A young adult with its bead tag. The colored beads allow for an easy and effective way to remotely identifying the individual without the necessity to capture it. Each color corresponds to a number and a combination of different colors provides the individual numeric identifier. In this case only the white bead is present, indicating that this is individual number 1. (Photo credits: G. Colosimo)</figcaption>
</figure>
</div>
<p>Among different conservation strategies, individuals translocation has proven an effective measure for TCI iguanas. A translocation of individuals entails the collection of adults (or young adults) from a source population to be introduced in a recipient area, usually identified within the historical range of a species. If no historical areas are available or known, a new location can also be selected as recipient area, as long as it presents the appropriate characteristics for the species to thrive.</p>
<p>A first translocation program was conducted in 2002 and 2003 <span class="citation" data-cites="Gerber2004 Gerber2007">(Gerber <em>et al.</em>, 2004; Gerber, 2007)</span>. This year, following up on an intensive project to eradicate invasive mammals from some of the islands in the vicinity of Providenciales, another translocation was performed. Between July and August 2023 we moved 74 adults from Little Water Cay to Grouper Cay. The project authorized by the Scientific Research Permit No.&nbsp;2023-06-30-32 issued by DECR, was funded through a Darwin grant and leaded by senior research scientist Dr.&nbsp;Glenn Gerber (San Diego Zoo Wildlife Alliance). We received support from many local political institutions as well from local tour operators.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.giulianocolosimo.com/posts/translocation/georgeandflesh.png" class="img-fluid figure-img"></p>
<figcaption>Flesh, a representative of the Department of Environment and Coastal Resources, with an adult male <em>Cyclura carinata</em>. Flesh is receiving help from George, a volunteer with years of field experience in the Turks and Caicos Islands. (Photo credits: Dodly).</figcaption>
</figure>
</div>
<p>Once captured, individuals are measured and sexed to make sure that an equal ratio of males and females are moved. Every individual is also assigned a unique identifier (Passive Integrated Trasponder-PIT), very much like the transponders that are used for house cats and dogs. These identifiers will ensure that, if recaptured in the future, that individual will be recognized as one of the animals already sampled. This is a more permanent solution to the application of colored beads. As beads are exposed, they can, eventually, fall from the animal following a fight between individual or the mating between males and females or simply because the wire used for attaching them to the nucal crest breaks.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.giulianocolosimo.com/posts/translocation/joemorgannick.png" class="img-fluid figure-img"></p>
<figcaption>Joe (left, U.S. National Park Service), Morgan (center, local tour operato) and Nickoy (right, Turks and Caicos National Trust), while preparing a young adult for the application of beads and radio frequency identifier (RFID) transponder. (Photo credits: G. Colosimo)</figcaption>
</figure>
</div>
<p>In future years it will be necessary to monitor the recipient island of Grouper Cay to make sure that the translocated animals have successfully acclimated to the new island. The best way to monitor the success of a translocation is to document the reproduction of the translocated individuals. In the next few years we will monitor for the presence of hatchlings or yearlings. Stay tuned.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.giulianocolosimo.com/posts/translocation/cycjuvi.png" class="img-fluid figure-img"></p>
<figcaption>A hatchling hiding in the vegetation. (Photo credits: G. Colosimo)</figcaption>
</figure>
</div>
<p>Did you like this post? Drop a comment down here or let me know by e-mail what you think of it or if you have questions or curiosities. Till next time.</p>
<p>Cheers</p>
<section id="references" class="level1">




</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-Gerber2004a" class="csl-entry">
Gerber, G.P. 2004. <a href="http://dx.doi.org/10.2305/IUCN.UK.2004.RLTS.T6026A12317199.en"><span class="nocase">Cyclura carinata. The IUCN Red List of Threatened Species 2004: e.T6026A12317199.</span></a>
</div>
<div id="ref-Gerber2007" class="csl-entry">
Gerber, G.P. 2007. <span class="nocase">Turks and Caicos iguana translocation program, Bahama Archipelago</span>. In: <em>Re-introduction news. Newsletter of the IUCN/SSC re-introduction specialist group, abu dhabi, UAE.</em> (P. S. Soorae, ed), p. 53. Abu Dhabi: IUCN/SSC Re-Introduction Specialist Group.
</div>
<div id="ref-Gerber2020" class="csl-entry">
Gerber, G.P., Colosimo, G. and Grant, T.D. 2020. <a href="https://doi.org/10.2305/IUCN.UK.2020-2.RLTS.T6026A3097754.en"><span class="nocase">Cyclura carinata. The IUCN Red List of Threatened Species</span></a>.
</div>
<div id="ref-Gerber2004" class="csl-entry">
Gerber, G.P., Keener, L., Jezier, B., Czekala, N.M., MacDonald, E.A. and Alberts, A.C. 2004. <span class="nocase">Effects of translocation on the blood chemistry, hematology, and endocrinology of critically endangered Turks and Caicos iguanas, (<em>Cyclura carinata</em>)</span>. In: <em>American association of zoo veterinarians</em>, p. 568.
</div>
<div id="ref-Welch2017" class="csl-entry">
Welch, M.E., Colosimo, G., Pasachnik, S.A., Malone, C.L., Hilton, J., Long, J., <em>et al.</em> 2017. <a href="https://doi.org/10.1007/s10592-016-0922-6"><span class="nocase">Molecular variation and population structure in critically endangered Turks and Caicos Rock Iguanas: identifying intraspecific conservation units and revising subspecific taxonomy</span></a>. <em>Conservation Genetics</em>, <strong>18</strong>: 479–493.
</div>
</div></section></div> ]]></description>
  <category>Field work</category>
  <category>Conservation</category>
  <category>Cyclura</category>
  <category>Turks and Caicos</category>
  <guid>https://www.giulianocolosimo.com/posts/translocation/</guid>
  <pubDate>Fri, 18 Aug 2023 22:00:00 GMT</pubDate>
  <media:content url="https://www.giulianocolosimo.com/posts/translocation/cycmale.png" medium="image" type="image/png" height="96" width="144"/>
</item>
<item>
  <title>Automated download of weather data from Italian monitoring stations.</title>
  <dc:creator>Giuliano Colosimo</dc:creator>
  <link>https://www.giulianocolosimo.com/posts/accessing_weather_data/</link>
  <description><![CDATA[ 





<p>Last year, during the Conservation Biology course I was teaching, I had planned to do a practical exercise and have the students download and analyse some historical weather data for Italy.</p>
<p>Not too long ago it was possible to download historical weather data relatively easily from a number of different websites. Unfortunately this option is no longer available and there really is only a handful of sites from which it is possible to download historical data for free.</p>
<p>One of them is <a href="https://mesonet.agron.iastate.edu/request/download.phtml">here</a>, hosted on the Iowa State University website. The user interface is pretty intuitive and it is possible to select from a pretty amazing variety of network of data from all over the world.</p>
<p>Another very cool thing about this portal is that it offers a few line of codes, in R and Python, to automate the download of the data of interest. I have tried the R script, but I couldn’t make it work “as is”. I did a few changes to the original code to make it do what it was supposed to do, and since I did it for my students I thought it would be nice to make a blog post. I here provide a full rundown on how to use the script. The description includes the installation of a few necessary packages to download historical weather data. The worked out example shows how to download data for the Italian peninsula, but with a few tweaks and changes it is possible to adapt it to download all data of interest.</p>
<p>Buckle up and lets begin. First of all, let me give you an overview of the OS and R version I am working with. After downloading the appropriate packages the code should work for all platforms. Regardless, I will start by sharing my session information.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sessionInfo</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>R version 4.6.1 (2026-06-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Rome
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] htmlwidgets_1.6.4 compiler_4.6.1    fastmap_1.2.0     cli_3.6.6        
 [5] tools_4.6.1       htmltools_0.5.9   otel_0.2.0        yaml_2.3.12      
 [9] rmarkdown_2.31    knitr_1.51        jsonlite_2.0.0    xfun_0.57        
[13] digest_0.6.39     rlang_1.3.0       evaluate_1.0.5   </code></pre>
</div>
</div>
<p>So, I pretty much just opened R and didn’t attach any package but the ones that automatically are loaded when you open a new working session.</p>
<p>To accomplish this task we do need to install and load a few packages that will allow R to interact with web pages and read/download information from the specified website. The code below will install on your machine the necessary packages. Of course, you will not need this step if the packages are already installed.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Installing the appropriate packages</span></span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">install.packages</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"jsonlite"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RCurl"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lubridate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dplyr"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ggplot2"</span>))</span></code></pre></div></div>
</div>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>The output of the above line of code is not shown, as the packages are already installed on my machine.</p>
</div>
</div>
<p>Once installed we can load the packages in the current working session.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Load packages in the working session</span></span>
<span id="cb4-2">x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"jsonlite"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RCurl"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lubridate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dplyr"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ggplot2"</span>)</span>
<span id="cb4-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(x, require, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">character.only =</span> T)</span></code></pre></div></div>
<div class="cell-output cell-output-stderr">
<pre><code>Loading required package: jsonlite</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>Loading required package: RCurl</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>Loading required package: lubridate</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>
Attaching package: 'lubridate'</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>The following objects are masked from 'package:base':

    date, intersect, setdiff, union</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>Loading required package: dplyr</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>
Attaching package: 'dplyr'</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>The following objects are masked from 'package:stats':

    filter, lag</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>Loading required package: ggplot2</code></pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>[[1]]
[1] TRUE

[[2]]
[1] TRUE

[[3]]
[1] TRUE

[[4]]
[1] TRUE

[[5]]
[1] TRUE</code></pre>
</div>
</div>
<p>Perfect. If you have a list with all TRUE values it means that everything worked fine, and we can move on to the next steps. We can now specify 2 important variables that will be used in the automated script. We need a start and an end date that will be used to identify the time window of interest for which we would like to download the data of interest.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># specify the date boundaries of our dataset</span></span>
<span id="cb16-2">date1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ISOdate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1990</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># start date in year, month, day format</span></span>
<span id="cb16-3">date2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ISOdate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2020</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">31</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># end date in year, month, day format</span></span></code></pre></div></div>
</div>
<p>The second step is to set 2 other variables containing the data network infrastructure from which we want to download the data and the specific country/state of interest.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">user.network <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ASOS"</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># data network</span></span>
<span id="cb17-2">user.state <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IT"</span>)     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># state</span></span></code></pre></div></div>
</div>
<p>If we were to do this procedure manually directly on the ISU web page at this point we will be selecting the appropriate country/state and network from the dedicated drop down menu, as shown in Figure&nbsp;1.</p>
<div id="fig-state_net" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-state_net-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://www.giulianocolosimo.com/posts/accessing_weather_data/data_and_network_blue.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-state_net-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Highlighted in blue is the drop down menu that we could use on the web page to select the specific country/state and data network of interest.
</figcaption>
</figure>
</div>
<p>One of the advantages of the automated procedure through R, though, is that once we have perfected the procedure for a specified the country/state and data network we can repeat the same procedure over and over with different states and or location of interest. Anyway, lets keep going with our procedure. From Figure&nbsp;1 it is possible to see that, after selecting the Italian ASOS network, a list of of available weather stations appears in the left box right underneath the <strong>Select Widget for IT_ASOS Network</strong> claim. What the web page is telling us is that of all the weather stations available for the ASOS network in Italy we can pick and choose the ones we want to download the data from. Unless we really know what we are doing and unless we know exactly the precise station we want data from we need to do a little more work to figure out how many stations are available, where they are and what is their specific ID.</p>
<p>So, using a little information taken directly from the URL bar of our browsers we can tell R to open a connection to the desired web page to download the information we need. We do this with the following few lines of code.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create and open a connection</span></span>
<span id="cb18-2">network <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(user.state, user.network, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"__"</span>)</span>
<span id="cb18-3">uri <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"https://mesonet.agron.iastate.edu/geojson/network/"</span>, network, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".geojson"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb18-4">data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">url</span>(uri)</span>
<span id="cb18-5">jdict <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fromJSON</span>(data)</span>
<span id="cb18-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">class</span>(jdict)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] "list"</code></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(jdict)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] "type"         "features"     "generated_at" "count"       </code></pre>
</div>
</div>
<p>We have created and opened a connection to a <em>.geojson</em> file from the specified webpage containing all the necessary information. All the data are then stored in an object that we have called <strong>jdict</strong>. This is a list with four elements named as indicated above. Based on the names of the list elements we can infer that the second element of the list has the features of interest to us. We can look the first 5 rows of the data frame contained in the second element of the <strong>jdict</strong> list.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>(jdict[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]])</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>     type   id properties.elevation properties.sname properties.time_domain
1 Feature EQYS               23.000        Sigonella             (2022-Now)
2 Feature LIBA               60.000         Amendola             (1944-Now)
3 Feature LIBC              161.000          Crotone             (1957-Now)
4 Feature LIBD               44.000             Bari             (1943-Now)
5 Feature LIBE              834.111  Monte S. Angelo            (2003-2025)
6 Feature LIBF               80.000           Foggia             (1943-Now)
  properties.archive_begin properties.archive_end properties.state
1               2022-04-12                   &lt;NA&gt;                 
2               1944-01-31                   &lt;NA&gt;             &lt;NA&gt;
3               1957-06-30                   &lt;NA&gt;             &lt;NA&gt;
4               1943-12-07                   &lt;NA&gt;             &lt;NA&gt;
5               2003-08-01             2025-03-04             &lt;NA&gt;
6               1943-09-30                   &lt;NA&gt;             &lt;NA&gt;
  properties.country properties.climate_site properties.wfo properties.tzname
1                 IT                      NA             NA       Europe/Rome
2                 IT                      NA             NA       Europe/Rome
3                 IT                      NA             NA       Europe/Rome
4                 IT                      NA             NA       Europe/Rome
5                 IT                      NA             NA       Europe/Rome
6                 IT                      NA             NA       Europe/Rome
  properties.ncdc81 properties.ncei91 properties.ugc_county properties.ugc_zone
1                NA                NA                    NA                  NA
2                NA                NA                    NA                  NA
3                NA                NA                    NA                  NA
4                NA                NA                    NA                  NA
5                NA                NA                    NA                  NA
6                NA                NA                    NA                  NA
  properties.county properties.sid properties.network properties.online
1                NA           EQYS           IT__ASOS              TRUE
2                NA           LIBA           IT__ASOS              TRUE
3                NA           LIBC           IT__ASOS              TRUE
4                NA           LIBD           IT__ASOS              TRUE
5                NA           LIBE           IT__ASOS             FALSE
6                NA           LIBF           IT__ASOS              TRUE
  properties.synop properties.attributes.METAR_RESET_MINUTE
1               NA                                       46
2            99999                                       55
3            99999                                       50
4            99999                                       50
5             9999                                        0
6               NA                                       50
  properties.attributes.HAS_PHOUR properties.attributes.GHCNH_ID geometry.type
1                               1                           &lt;NA&gt;         Point
2                               1                           &lt;NA&gt;         Point
3                               1                           &lt;NA&gt;         Point
4                               1                           &lt;NA&gt;         Point
5                            &lt;NA&gt;                           &lt;NA&gt;         Point
6                               1                           &lt;NA&gt;         Point
  geometry.coordinates
1         14.92, 37.40
2     15.7139, 41.5381
3     17.0792, 38.9967
4     16.7650, 41.1381
5     15.9476, 41.7084
6     15.5350, 41.4329</code></pre>
</div>
</div>
<p>As anticipated, this element contains all the information we need. There are 108 stations in Italy from where we can download data. Of the many variables for each location what is more important to us is the <strong>id</strong> of each station, its <strong>properties.sname</strong>, the <strong>properties.time_domain</strong> and the <strong>geometry.coordinates</strong> of each station. In fact, as a simple exercise we can make a plot to see how and where are the stations distributed.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1">stationsPlot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unlist</span>(jdict<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>features<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>geometry<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>coordinates), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb24-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(stationsPlot[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,], stationsPlot[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">asp =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span></code></pre></div></div>
</div>
<div id="fig-weather_stations" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-weather_stations-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://www.giulianocolosimo.com/posts/accessing_weather_data/weather_station.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-weather_stations-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: Location of all weather stations around available from the ISU repository.
</figcaption>
</figure>
</div>
<p>It is interesting to see that there are so many stations that they can pretty much reproduce the outline and profile of the iconic Italian boot (Figure&nbsp;2)! This is all nice and good. Now lets get to the fun part. Let us say that we want to download data from ALL the stations available. Using the web interface from Figure&nbsp;1 we would be selecting all the stations from the left box, move them to the right box. Then go to the right side of the page (Figure&nbsp;3) and specify a number of things like the kind of desired output (CSV rather than TXT rather than DAT), the appropriate dates for the time window of interest and what kind of weather variable we would like data for (temperature, rain, wind, etc. etc. etc.).</p>
<div id="fig-download_protocol" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-download_protocol-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://www.giulianocolosimo.com/posts/accessing_weather_data/data_and_network_red.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-download_protocol-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;3: Highlighted in red is the section of the page where to specifiy the kind of information needed, the time window of interest and the specific output format.
</figcaption>
</figure>
</div>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>Please remember these two points. First, not all stations will have data available for the time window selected. Some stations were only recently activated and it is therefore unlikely that we will be able to get data since, for example, 1970. The other issue is related to the type of variable available for download. The only variable available for bulk download in many data network not US based is only temperature!</p>
</div>
</div>
<p>Now we create a string that contains an URL with the start date and the end date. This is the URL that would appear every time we would download manually the information from the website. At this time we still do not have any information re which station we request the data from.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1">service <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"https://mesonet.agron.iastate.edu/cgi-bin/request/asos.py?"</span></span>
<span id="cb25-2">service <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(service, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"data=all&amp;tz=Etc/UTC&amp;format=comma&amp;latlon=yes&amp;"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb25-3">service <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(service, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"year1="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">year</span>(date1), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&amp;month1="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">month</span>(date1), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&amp;day1="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mday</span>(date1), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&amp;"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb25-4">service <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(service, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"year2="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">year</span>(date2), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&amp;month2="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">month</span>(date2), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&amp;day2="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mday</span>(date2), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&amp;"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb25-5">service</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] "https://mesonet.agron.iastate.edu/cgi-bin/request/asos.py?data=all&amp;tz=Etc/UTC&amp;format=comma&amp;latlon=yes&amp;year1=1990&amp;month1=1&amp;day1=1&amp;year2=2020&amp;month2=12&amp;day2=31&amp;"</code></pre>
</div>
</div>
<p>Now we set the working directory to a dedicated folder. Note that the data could be large several GB, and it may be convenient to store them on an external hard drive.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setwd</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"path/to/your/folder/of/choice"</span>)</span></code></pre></div></div>
</div>
<p>OK. We are almost there. The final part of this tutorial consists in creating a loop that will take the part of the URL that is constant every time and add, recursively until the very last one, the ID of the weather station we want the data from. Once again, when you run the script make sure that you have enough space on your dedicated folder and that you have enough time and a good internet connection to download all the data. Needless to say that if you first want to try the script on only a few stations you can subset the stations ID and select only 1 or 2 for a quick test.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1">it_stations_id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> jdict<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>features<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>id</span>
<span id="cb28-2">it_stations_nm <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> jdict<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>features<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>properties<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sname</span>
<span id="cb28-3"></span>
<span id="cb28-4"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(it_stations_id[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])){</span>
<span id="cb28-5">  uri <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(service, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"station="</span>, it_stations_id[i], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb28-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Network:"</span>, network, </span>
<span id="cb28-7">              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Downloading:"</span>, it_stations_nm[i], it_stations_id[i], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span>))</span>
<span id="cb28-8">  data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">url</span>(uri)</span>
<span id="cb28-9">  datestring1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(date1, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%Y%m%d"</span>)</span>
<span id="cb28-10">  datestring2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(date2, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%Y%m%d"</span>)</span>
<span id="cb28-11">  outfn <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(network, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>, it_stations_id[i], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>, datestring1, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_to_"</span>, datestring2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb28-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">download.file</span>(uri, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(outfn, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".csv"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auto"</span>)</span>
<span id="cb28-13">}</span></code></pre></div></div>
</div>
<p>As the loop proceeds you should see information on what is being downloaded printed on your R prompt.</p>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Important
</div>
</div>
<div class="callout-body-container callout-body">
<p>Depending on your internet connection it may happen that your download procedure will stop because of time out issues! Unfortunately I am yet to find a proper solution to this problem. Of course, you should make sure that you work with a stable and fast internet connection. If the issue manifests itself, and it usually does with large files, what you can do is to edit the vector of stations to download to momentary exclude the station that gives you problem, finish the download of the other stations and then come back to the one that gives problem to download it by itself.</p>
</div>
</div>
<p>Once the procedure is completed you will have all your data ready to be analysed in your folder. In the next post we will try to look at some of the downloaded data and make a few basic analysis.</p>
<p>Did you like this post? Drop a comment down here or let me know by e-mail what you think of it or if you have questions or curiosities. Till next time.</p>
<p>Cheers</p>



 ]]></description>
  <category>R</category>
  <category>Climate change</category>
  <category>Automated tasks</category>
  <guid>https://www.giulianocolosimo.com/posts/accessing_weather_data/</guid>
  <pubDate>Mon, 03 Jul 2023 22:00:00 GMT</pubDate>
  <media:content url="https://www.giulianocolosimo.com/posts/accessing_weather_data/asos_italy.png" medium="image" type="image/png" height="160" width="144"/>
</item>
</channel>
</rss>
