-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba97c30
commit 99888da
Showing
252 changed files
with
46,441 additions
and
1,143 deletions.
There are no files selected for viewing
Binary file added
BIN
+54.7 KB
_downloads/203b418e4a4d604663eea6a5c1037633/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
BIN
+171 KB
...ds/7951bf35557cb233145e9a0d7465fda3/geosnap-visualize-indexplot_seq-1.hires.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
BIN
+319 KB
_downloads/968d4ead8e5e1095d224e3e33676c074/geosnap-visualize-indexplot_seq-1.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
_downloads/c838af3ae5fbb69ae7cccae2c0c8b488/geosnap-visualize-indexplot_seq-1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
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.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 — 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">"""Utilities for fetching data from GADM."""</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">"""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'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'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"> """</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">"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"</span><span class="p">,</span> | ||
<span class="n">simplecache</span><span class="o">=</span><span class="p">{</span><span class="s2">"cache_storage"</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">"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">"</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> | ||
© Copyright 2023, geosnap developers.<br/> | ||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 7.2.6.<br/> | ||
</p> | ||
</div> | ||
</footer> | ||
</body> | ||
</html> |
Oops, something went wrong.