Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 29, 2024
1 parent ba97c30 commit 99888da
Show file tree
Hide file tree
Showing 252 changed files with 46,441 additions and 1,143 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pandas as pd
from geosnap.visualize import indexplot_seq
import matplotlib.pyplot as plt
df_LA = pd.read_csv("../../examples/data/LA_sequences.csv", converters={'GEO2010': lambda x: str(x)})
indexplot_seq(df_LA, clustering="seqC1", palette="pastel", ncols=3)
plt.show()
Binary file added _images/geosnap-visualize-indexplot_seq-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/geosnap_long.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
841 changes: 841 additions & 0 deletions _modules/geosnap/_data.html

Large diffs are not rendered by default.

956 changes: 956 additions & 0 deletions _modules/geosnap/analyze/_model_results.html

Large diffs are not rendered by default.

773 changes: 773 additions & 0 deletions _modules/geosnap/analyze/dynamics.html

Large diffs are not rendered by default.

825 changes: 825 additions & 0 deletions _modules/geosnap/analyze/geodemo.html

Large diffs are not rendered by default.

310 changes: 310 additions & 0 deletions _modules/geosnap/analyze/incs.html

Large diffs are not rendered by default.

326 changes: 326 additions & 0 deletions _modules/geosnap/analyze/network.html

Large diffs are not rendered by default.

346 changes: 346 additions & 0 deletions _modules/geosnap/analyze/segdyn.html

Large diffs are not rendered by default.

378 changes: 378 additions & 0 deletions _modules/geosnap/harmonize/harmonize.html

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _modules/geosnap/io/constructors.html

Large diffs are not rendered by default.

205 changes: 205 additions & 0 deletions _modules/geosnap/io/gadm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
<!DOCTYPE html>

<html lang="en" data-content_root="../../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>geosnap.io.gadm &#8212; geosnap v0.13.1 Manual</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../../_static/bootstrap-sphinx.css?v=9afac83c" />
<link rel="stylesheet" type="text/css" href="../../../_static/plot_directive.css" />
<script src="../../../_static/documentation_options.js?v=b4617fb1"></script>
<script src="../../../_static/doctools.js?v=888ff710"></script>
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="icon" href="../../../_static/geosnap.ico"/>
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript" src="../../../_static/js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="../../../_static/js/jquery-fix.js"></script>
<script type="text/javascript" src="../../../_static/bootstrap-3.4.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../../_static/bootstrap-sphinx.js"></script>

</head><body>

<div id="navbar" class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../../../index.html">
geosnap</a>
<span class="navbar-text navbar-version pull-left"><b>0.13.1</b></span>
</div>

<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">

<li><a href="../../../installation.html">Installation</a></li>
<li><a href="../../../api.html">API</a></li>
<li><a href="../../../data.html">Data</a></li>
<li><a href="https://oturns.github.io/geosnap-guide/">User Guide</a></li>
<li><a href="../../../references.html">References</a></li>


<li class="dropdown globaltoc-container">
<a role="button"
id="dLabelGlobalToc"
data-toggle="dropdown"
data-target="#"
href="../../../index.html">Site <b class="caret"></b></a>
<ul class="dropdown-menu globaltoc"
role="menu"
aria-labelledby="dLabelGlobalToc"><p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../installation.html">Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../installation.html#installing-a-released-version">Installing a released version</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../installation.html#installing-development-version">Installing development version</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../api.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../api.html#io-module">IO Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../api.html#analyze-module">Analyze Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../api.html#harmonize-module">Harmonize Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../api.html#visualize-module">Visualize Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../api.html#util-module">Util Module</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../references.html">References</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../data.html">Data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../data.html#tabular-data">Tabular Data</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../data.html#geo-data">Geo Data</a></li>
</ul>
</li>
</ul>
</ul>
</li>

<li class="dropdown">
<a role="button"
id="dLabelLocalToc"
data-toggle="dropdown"
data-target="#"
href="#">Page <b class="caret"></b></a>
<ul class="dropdown-menu localtoc"
role="menu"
aria-labelledby="dLabelLocalToc"></ul>
</li>






</ul>



<form class="navbar-form navbar-right" action="../../../search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>

</div>
</div>
</div>

<div class="container">
<div class="row">
<div class="body col-md-12 content" role="main">

<h1>Source code for geosnap.io.gadm</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;Utilities for fetching data from GADM.&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">tempfile</span>

<span class="kn">import</span> <span class="nn">geopandas</span> <span class="k">as</span> <span class="nn">gpd</span>


<div class="viewcode-block" id="get_gadm">
<a class="viewcode-back" href="../../../generated/geosnap.io.get_gadm.html#geosnap.io.get_gadm">[docs]</a>
<span class="k">def</span> <span class="nf">get_gadm</span><span class="p">(</span><span class="n">code</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">use_fsspec</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">gpkg</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">n_retries</span><span class="o">=</span><span class="mi">3</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Collect data from GADM as a geodataframe.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> code : str</span>
<span class="sd"> three character ISO code for a country</span>
<span class="sd"> level : int, optional</span>
<span class="sd"> which geometry level to collect, by default 0</span>
<span class="sd"> use_fsspec : bool</span>
<span class="sd"> whether to use the `fsspec` library</span>
<span class="sd"> gpkg : bool</span>
<span class="sd"> whether to read from a geopackage or shapefile. If True,</span>
<span class="sd"> geopackage will be read; shapefile if False. Ignored if using fsspec</span>
<span class="sd"> n_retries : int optional</span>
<span class="sd"> number of retries in case read fails from direct stream from GADM.</span>
<span class="sd"> Ignored if using fsspec.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> geopandas.GeoDataFrame</span>
<span class="sd"> geodataframe containing GADM data</span>

<span class="sd"> Notes</span>
<span class="sd"> -------</span>
<span class="sd"> If not using the fsspec package, this function uses fiona&#39;s syntax to read a geodataframe directly with</span>
<span class="sd"> geopandas `read_file` function. Unfortunately, sometimes the operation fails</span>
<span class="sd"> before the read is complete resulting in an error--or occasionally, a</span>
<span class="sd"> geodataframe with missing rows. Repeating the call sometimes helps.</span>

<span class="sd"> When using fsspec, the function doesn&#39;t suffer these issues, but requires an additional dependency.</span>
<span class="sd"> If fsspec is available, this function its syntax to store a temporary file which is then</span>
<span class="sd"> read in by geopandas. In theory, the file could be read into fsspec directly</span>
<span class="sd"> without storing it in a temporary directory, but when reading a bytestream of GPKG,</span>
<span class="sd"> geopandas does not allow the specification of a particular layer (so reading GPKG</span>
<span class="sd"> with this method would always returns the layer with index 0 in the geopackage file).</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">code</span> <span class="o">=</span> <span class="n">code</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>
<span class="kn">import</span> <span class="nn">fsspec</span>

<span class="k">with</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">TemporaryDirectory</span><span class="p">()</span> <span class="k">as</span> <span class="n">temp_path</span><span class="p">:</span>
<span class="k">with</span> <span class="n">fsspec</span><span class="o">.</span><span class="n">open</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;simplecache::zip://*.gpkg::https://biogeo.ucdavis.edu/data/gadm3.6/gpkg/gadm36_</span><span class="si">{</span><span class="n">code</span><span class="si">}</span><span class="s2">_gpkg.zip&quot;</span><span class="p">,</span>
<span class="n">simplecache</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;cache_storage&quot;</span><span class="p">:</span> <span class="n">temp_path</span><span class="p">},</span>
<span class="p">):</span>
<span class="n">gdf</span> <span class="o">=</span> <span class="n">gpd</span><span class="o">.</span><span class="n">read_file</span><span class="p">(</span>
<span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">temp_path</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">temp_path</span><span class="p">)[</span><span class="mi">0</span><span class="p">]),</span>
<span class="n">layer</span><span class="o">=</span><span class="sa">f</span><span class="s2">&quot;gadm36_</span><span class="si">{</span><span class="n">code</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">level</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">gdf</span></div>

</pre></div>

</div>

</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-right">
<a href="#">Back to top</a>

<br/>


</p>
<p>
&copy; Copyright 2023, geosnap developers.<br/>
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 7.2.6.<br/>
</p>
</div>
</footer>
</body>
</html>
Loading

0 comments on commit 99888da

Please sign in to comment.