<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/simple-spatial-modelling-part-3-exercises/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.r-exercises.com/2018/05/24/simple-spatial-modelling-exercises-part-3/"> R-exercises</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>So far, we have learned how to count spatial variability in our model. Please look at these two previous exercises <a rel="nofollow" href="https://www.r-exercises.com/2018/04/26/simple-spatial-modelling-excercises-part-1/" target="_blank">here</a> and <a rel="nofollow" href="https://www.r-exercises.com/2018/05/10/simple-spatial-modelling-exercises-part-2/" target="_blank">here</a> if you haven’t tried it yet. However, it only represents 1-Dimension model. On this exercise, we will try to expand our spatial consideration into 2-Dimension model. </p>
<p>Have a look at this plan view below to get an illustration of how the 2-dimensions model will work. </p>
<p>The water levels are store in a 2-D array. they are numbered as follows:<br>
<a rel="nofollow" href="https://i1.wp.com/www.r-exercises.com/wp-content/uploads/2018/05/Screenshot-2018-05-03-00.36.24.png?ssl=1" target="_blank"><img sizes="(max-width: 753px) 100vw, 753px" src="https://i1.wp.com/www.r-exercises.com/wp-content/uploads/2018/05/Screenshot-2018-05-03-00.36.24.png?w=450&ssl=1" alt="" class="wp-image-11464" data-recalc-dims="1"></a></p>
<p>The water flows are store in 2 different 2-D arrays.<br>
1. qv : defines water flows between buckets down the screen (in plan view)<br>
2. qh : defines water flows between buckets across the screen. </p>
<p><a rel="nofollow" href="https://i0.wp.com/www.r-exercises.com/wp-content/uploads/2018/05/Screenshot-2018-05-03-00.34.31.png?ssl=1" target="_blank"><img sizes="(max-width: 796px) 100vw, 796px" src="https://i0.wp.com/www.r-exercises.com/wp-content/uploads/2018/05/Screenshot-2018-05-03-00.34.31.png?w=450&ssl=1" alt="" class="wp-image-11462" data-recalc-dims="1"></a><br>
Let’s get into the modelling by cracking the exercises below. Answers to these exercises are available <a rel="nofollow" href="https://www.r-exercises.com/2018/05/24/simple-spatial-modelling-solutions-part-3/" target="_blank">here</a>. If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.</p>
<p><strong>Exercise 1</strong><br>
Set all the required settings for the model:<br>
a. set number of timesteps. Here we use 1000 (it shows how many timesteps in which we are going to run the model, you can change it as you want)<br>
b. set the total number of cell, here we have 25 x 25 water tanks<br>
c. set timestep in seconds; here is 1<br>
d. set time at the start of simulations<br>
e. set k between each water tank. Here we set a uniform value of k; 0.01</p>
<p><strong>Exercise 2</strong><br>
create matrix H for initial water level in the water tank</p>
<p><strong>Exercise 3</strong><br>
Set boundary conditions for the model; here we have water flow (qh) into the water tanks from three sides (top, left and right) and water flowing out on the bottom (qv;see the plan view). Water flow to the right and to the bottoms are considered positive. Don’t forget to declare the matrix for qh and qv.</p>
<p><strong>Exercise 4</strong><br>
Create an output models for every 100 timesteps </p>
<p><strong>Exercise 5</strong><br>
Run the model by creating loop for qh, qv, water storage update, and models output (Remember the threshold loop on latest previous exercise?)</p>
<p><strong>Exercise 6</strong><br>
Plot model output using contour plot</p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a rel="nofollow" href="https://www.r-exercises.com/2018/04/26/simple-spatial-modelling-excercises-part-1/" title="Simple Spatial Modeling – Part 1: Exercises" target="_blank">Simple Spatial Modeling – Part 1: Exercises </a></li>
<li><a rel="nofollow" href="https://www.r-exercises.com/2017/01/08/descriptive-analytics-part-6-interactive-dashboard-22/" title="Descriptive Analytics-Part 6: Interactive dashboard ( 2/2)" target="_blank">Descriptive Analytics-Part 6: Interactive dashboard ( 2/2) </a></li>
<li><a rel="nofollow" href="https://www.r-exercises.com/2018/02/23/practice-you-ggplot-skills-exercises/" title="Practice Your ggplot Skills: Exercises" target="_blank">Practice Your ggplot Skills: Exercises </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/start-here-to-learn-r/" target="_blank">Explore all our (>1000) R exercises</a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/r-courses/" target="_blank">Find an R course using our R Course Finder</a> directory</li>
</ol>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://www.r-exercises.com/2018/05/24/simple-spatial-modelling-exercises-part-3/"> R-exercises</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/csatNI9cyUw" height="1"></a></div>