<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Proximity Index — proximity.index • spatialEco</title>


<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!-- Bootstrap -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script>

<!-- bootstrap-toc -->
<link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script>

<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" />

<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script>

<!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>

<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>




<meta property="og:title" content="Proximity Index — proximity.index" />
<meta property="og:description" content="Calculates proximity index for a set of polygons" />




<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>

<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->



  </head>

  <body data-spy="scroll" data-target="#toc">
    <div class="container template-reference-topic">
      <header>
      <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">spatialEco</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.3-7</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../index.html">
    <span class="fas fa-home fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="https://github.com/jeffreyevans/spatialEco/">
    <span class="fab fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
      
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      

      </header>

<div class="row">
  <div class="col-md-9 contents">
    <div class="page-header">
    <h1>Proximity Index</h1>
    <small class="dont-index">Source: <a href='https://github.com/jeffreyevans/spatialEco/blob/master/R/proximity.index.R'><code>R/proximity.index.R</code></a></small>
    <div class="hidden name"><code>proximity.index.Rd</code></div>
    </div>

    <div class="ref-description">
    <p>Calculates proximity index for a set of polygons</p>
    </div>

    <pre class="usage"><span class='fu'>proximity.index</span><span class='op'>(</span><span class='va'>x</span>, y <span class='op'>=</span> <span class='cn'>NULL</span>, min.dist <span class='op'>=</span> <span class='fl'>0</span>, max.dist <span class='op'>=</span> <span class='fl'>1000</span>, background <span class='op'>=</span> <span class='cn'>NULL</span><span class='op'>)</span></pre>

    <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
    <table class="ref-arguments">
    <colgroup><col class="name" /><col class="desc" /></colgroup>
    <tr>
      <th>x</th>
      <td><p>A polygon class sp or sf object</p></td>
    </tr>
    <tr>
      <th>y</th>
      <td><p>Optional column in data containing classes</p></td>
    </tr>
    <tr>
      <th>min.dist</th>
      <td><p>Minimum threshold distance</p></td>
    </tr>
    <tr>
      <th>max.dist</th>
      <td><p>Maximum neighbor distance</p></td>
    </tr>
    <tr>
      <th>background</th>
      <td><p>Optional value in y column indicating background value</p></td>
    </tr>
    </table>

    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p>A vector equal to nrow(x) of proximity index values, if a background value is 
specified NA values will be returned in the position(s) of the specified class</p>
    <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2>

    <p>Gustafson, E.J., &amp; G.R. Parker (1994) Using an Index of Habitat Patch Proximity 
  for Landscape Design. Landscape and Urban Planning 29:117-130</p>
    <h2 class="hasAnchor" id="author"><a class="anchor" href="#author"></a>Author</h2>

    <p>Jeffrey S. Evans  &lt;jeffrey_evans@tnc.org&gt;</p>

    <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
    <pre class="examples"><div class='input'><span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://github.com/edzer/sp/'>sp</a></span><span class='op'>)</span>
<span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://r-forge.r-project.org/projects/rgeos/'>rgeos</a></span><span class='op'>)</span>

<span class='co'># Create test polygons</span>
<span class='fu'><a href='https://rdrr.io/r/utils/data.html'>data</a></span><span class='op'>(</span><span class='va'>meuse</span><span class='op'>)</span>
  <span class='fu'><a href='https://rdrr.io/pkg/sp/man/coordinates.html'>coordinates</a></span><span class='op'>(</span><span class='va'>meuse</span><span class='op'>)</span> <span class='op'>=</span> <span class='op'>~</span><span class='va'>x</span><span class='op'>+</span><span class='va'>y</span>
  <span class='va'>meuse_poly</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/pkg/rgeos/man/misc-gBuffer.html'>gBuffer</a></span><span class='op'>(</span><span class='va'>meuse</span>, width <span class='op'>=</span> <span class='va'>meuse</span><span class='op'>$</span><span class='va'>elev</span> <span class='op'>*</span> <span class='fl'>5</span>, byid <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
    <span class='va'>meuse_poly</span><span class='op'>$</span><span class='va'>LU</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/sample.html'>sample</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"forest"</span>,<span class='st'>"nonforest"</span><span class='op'>)</span>, <span class='fu'><a href='https://rdrr.io/pkg/raster/man/ncell.html'>nrow</a></span><span class='op'>(</span><span class='va'>meuse_poly</span><span class='op'>)</span>, 
                            replace<span class='op'>=</span><span class='cn'>TRUE</span><span class='op'>)</span> 

<span class='co'># All polygon proximity index 1000 radius  </span>
<span class='op'>(</span> <span class='va'>pidx</span> <span class='op'>&lt;-</span><span class='fu'>proximity.index</span><span class='op'>(</span><span class='va'>meuse_poly</span>, min.dist <span class='op'>=</span> <span class='fl'>1</span><span class='op'>)</span> <span class='op'>)</span>
</div><div class='output co'>#&gt;   [1]    4.0691083    2.6466057    6.7582495    3.6211467    8.5777691
#&gt;   [6]    6.3107075    7.5021144   11.6112601  135.6778243    7.1562374
#&gt;  [11]    8.0282170   10.1865047   11.3193271  174.8850681   50.6947541
#&gt;  [16]   12.7122574   27.0654203  163.2308864    5.9793477   96.3136937
#&gt;  [21]   58.1292009    5.5735312    4.2505419   44.6475848   42.8492433
#&gt;  [26]    5.5938752  149.4281415   51.2314371   91.4148851    2.6817618
#&gt;  [31]    2.9612329    7.1385269    4.9317746  835.1449283  863.8099437
#&gt;  [36]    4.3364655    5.6939296    4.9948962    3.9143680    4.5444255
#&gt;  [41]    6.1662745   10.9387817   13.0696514  434.8304739  149.4057313
#&gt;  [46]    7.5584335   11.2256324   17.3882633    9.0376185    7.3254827
#&gt;  [51]    4.2131538    5.7236787   34.3584393    6.5586748    4.6921334
#&gt;  [56]    5.2407695   15.7029484    5.9051589   51.7105874   10.6653019
#&gt;  [61]    7.1375546    4.7308111    4.0837690 3879.8989762    5.9824296
#&gt;  [66]    3.7368343    2.7452016 2751.2569748   13.8128904   15.4606506
#&gt;  [71]   14.2598696    7.7202356   14.4515749   55.2737719   41.8612908
#&gt;  [76]   17.1367352  492.4604630    4.6827225    5.9717959    5.7555414
#&gt;  [81]   10.3919211    1.2412646    2.7163642   17.3040371    7.7205413
#&gt;  [86]   11.7109409    9.4622190    6.9922952    5.6637993    2.6807066
#&gt;  [91]   10.2998316    1.8040876    3.2301580    3.0214332    6.9487796
#&gt;  [96]    3.0561684    2.7260015    4.8758878   34.4242384    8.3126468
#&gt; [101]    2.8243319    1.7894614    7.1192568   12.3329930    4.1661313
#&gt; [106]    2.4941288    7.9570808    2.7466233    4.6879856   53.3815889
#&gt; [111] 2120.4412903   11.4208445    9.5953485    4.6588709 2827.5737375
#&gt; [116]    5.9300668    4.1231358    0.9167226    9.4474281    4.4985901
#&gt; [121]    9.2947793   11.8890387    6.1728133  120.0154071    8.3578787
#&gt; [126]  393.6277570   20.2122307   21.8047057   20.9520726   89.9439135
#&gt; [131]   13.3122768    8.9606043   14.3696212   26.1369201   15.1469821
#&gt; [136]   14.2984925    9.3501514  309.1889785  395.7221805  291.2010187
#&gt; [141]    4.5611518    2.9938017    2.4230841    4.5338157    5.0095533
#&gt; [146]    1.7749416    1.2959121    0.7084818    2.4987104    2.6685246
#&gt; [151]    8.1022015   10.0690246    2.9409043    3.4987681    0.1884891</div><div class='input'>  <span class='va'>pidx</span><span class='op'>[</span><span class='va'>pidx</span> <span class='op'>&gt;</span> <span class='fl'>100</span><span class='op'>]</span> <span class='op'>&lt;-</span> <span class='fl'>100</span>

<span class='co'># Class-level proximity index 1000 radius</span>
<span class='op'>(</span> <span class='va'>pidx.class</span> <span class='op'>&lt;-</span> <span class='fu'>proximity.index</span><span class='op'>(</span><span class='va'>meuse_poly</span>, y <span class='op'>=</span> <span class='st'>"LU"</span>, min.dist <span class='op'>=</span> <span class='fl'>1</span><span class='op'>)</span> <span class='op'>)</span>
</div><div class='output co'>#&gt;   [1] 3.294282e+00 4.290776e-01 1.243883e+00 1.604680e+02 9.499911e+01
#&gt;   [6] 2.316585e+00 6.722573e-01 2.908815e+00 4.665213e+00 9.408488e+00
#&gt;  [11] 9.947692e+00 1.463165e+02 3.555373e+00 7.631488e-01 7.089596e-01
#&gt;  [16] 2.732863e+00 4.512374e+00 3.696158e+00 2.585097e+00 3.256225e-01
#&gt;  [21] 3.668733e+00 3.599250e+00 1.425955e+00 4.299216e+00 5.566744e+00
#&gt;  [26] 1.853422e+00 1.878212e+00 1.110384e+01 2.937127e+00 1.821965e+00
#&gt;  [31] 1.183481e+02 2.354199e+00 1.235995e+01 1.224123e+01 3.772465e+00
#&gt;  [36] 1.436612e+00 1.390802e+00 1.812419e+00 1.663672e+00 1.451508e+00
#&gt;  [41] 3.500349e+00 4.612958e+01 6.592120e+00 2.526119e+01 1.003136e+00
#&gt;  [46] 4.100942e+01 8.920775e+01 4.282638e+02 3.463507e+00 1.908194e+00
#&gt;  [51] 3.335599e+00 2.241522e+00 7.605047e+00 2.750037e+03 4.123325e+00
#&gt;  [56] 7.371148e+00 1.071663e+00 2.975188e+00 3.386020e+00 7.650077e-01
#&gt;  [61] 7.863166e-01 1.562366e+00 3.634207e+00 7.570321e+00 7.453502e-01
#&gt;  [66] 4.704488e+01 2.118383e+03 2.009549e+00 1.294579e-01 2.415250e+00
#&gt;  [71] 6.410884e+00 3.833918e+02 1.885555e+01 2.026699e+00 7.030699e+00
#&gt;  [76] 7.924055e+00 2.843775e-01 2.805575e-01 3.561369e+00 3.535028e+00
#&gt;  [81] 3.667829e+00 3.311421e+00 1.706540e+00 5.592361e+01 3.182964e+00
#&gt;  [86] 5.545559e+00 8.322498e+02 8.625234e+02 2.908488e+00 3.415019e+00
#&gt;  [91] 5.347815e+00 3.667214e+00 1.854930e+00 1.256198e+00 1.640988e+00
#&gt;  [96] 1.699769e+00 8.852561e+00 3.876984e+03 1.877535e+00 4.123216e+00
#&gt; [101] 3.640813e+00 1.104316e+00 7.248399e+00 1.911219e+00 1.610313e+00
#&gt; [106] 2.816808e+03 1.352976e+00 5.624929e+00 3.348357e+00 8.815287e+01
#&gt; [111] 1.362080e+01 7.176414e+00 3.065642e+00 4.195462e+00 4.525480e+00
#&gt; [116] 1.822586e+00 5.788220e+00 8.441812e-02 9.119686e-01 1.907082e+00
#&gt; [121] 3.704004e+00 5.281644e+00 5.794666e+00 4.432388e+01 4.202667e+01
#&gt; [126] 1.470516e+02 4.932932e+01 1.965141e+00 1.692873e+00 1.648694e+00
#&gt; [131] 2.279054e+00 1.912779e+00 3.066484e+00 1.989303e+00 3.307552e+00
#&gt; [136] 2.714378e+00 1.774366e+00 1.796612e+00 2.863612e+00 5.323905e+00
#&gt; [141] 1.822709e+00 4.306337e+00 2.632085e+00 1.566964e+01 1.077950e+00
#&gt; [146] 1.877225e+00 5.883807e+00 9.118132e-01 1.195186e+00 1.724343e+00
#&gt; [151] 2.494799e+00 3.147614e+00 1.682421e+00 1.207022e+01 6.555152e-01</div><div class='input'>  <span class='va'>pidx.class</span><span class='op'>[</span><span class='va'>pidx.class</span> <span class='op'>&gt;</span> <span class='fl'>100</span><span class='op'>]</span> <span class='op'>&lt;-</span> <span class='fl'>100</span>  
  
<span class='co'># plot index for all polygons</span>
<span class='va'>meuse_poly</span><span class='op'>$</span><span class='va'>pidx</span> <span class='op'>&lt;-</span> <span class='va'>pidx</span>
  <span class='fu'><a href='https://rdrr.io/pkg/sp/man/spplot.html'>spplot</a></span><span class='op'>(</span><span class='va'>meuse_poly</span>, <span class='st'>"pidx"</span><span class='op'>)</span>
</div><div class='img'><img src='proximity.index-1.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># plot index for class-level polygons </span>
<span class='va'>meuse_poly</span><span class='op'>$</span><span class='va'>cpidx</span> <span class='op'>&lt;-</span> <span class='va'>pidx.class</span>
  <span class='fu'><a href='https://rdrr.io/pkg/sp/man/spplot.html'>spplot</a></span><span class='op'>(</span><span class='va'>meuse_poly</span>, <span class='st'>"cpidx"</span><span class='op'>)</span>
</div><div class='img'><img src='proximity.index-2.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># plot index for just forest class</span>
<span class='va'>forest</span> <span class='op'>&lt;-</span> <span class='va'>meuse_poly</span><span class='op'>[</span><span class='va'>meuse_poly</span><span class='op'>$</span><span class='va'>LU</span> <span class='op'>==</span> <span class='st'>"forest"</span>,<span class='op'>]</span>
  <span class='fu'><a href='https://rdrr.io/pkg/sp/man/spplot.html'>spplot</a></span><span class='op'>(</span><span class='va'>forest</span>, <span class='st'>"cpidx"</span><span class='op'>)</span>
</div><div class='img'><img src='proximity.index-3.png' alt='' width='700' height='433' /></div><div class='input'>  
</div></pre>
  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
    <nav id="toc" data-toggle="toc" class="sticky-top">
      <h2 data-toc-skip>Contents</h2>
    </nav>
  </div>
</div>


      <footer>
      <div class="copyright">
  <p>Developed by Jeffrey S. Evans.</p>
</div>

<div class="pkgdown">
  <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>

      </footer>
   </div>

  


  </body>
</html>


