Adjacency Simplicial Complex Module¶
You can try out spatial-tda by using the cloud-computing platforms below without having to install anything on your computer:
Installation¶
To install spatial_tda, use:
In [1]:
Copied!
# !pip install -U spatial-tda
# !pip install -U spatial-tda
Import Libraries¶
In [2]:
Copied!
import geopandas as gpd
import matplotlib.pyplot as plt
import geopandas as gpd
import matplotlib.pyplot as plt
Import Geospatial Data for the Analysis¶
In [4]:
Copied!
arlington_svi.head(2)
arlington_svi.head(2)
Out[4]:
| FIPS | EP_POV | EP_UNEMP | EP_PCI | EP_NOHSDP | EP_UNINSUR | EP_AGE65 | EP_AGE17 | EP_DISABL | EP_SNGPNT | EP_LIMENG | EP_MINRTY | EP_MUNIT | EP_MOBILE | EP_CROWD | EP_NOVEH | EP_GROUPQ | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 51013100100 | 1.2 | 2.1 | 76748.0 | 1.4 | 1.9 | 13.6 | 29.6 | 5.7 | 6.4 | 2.3 | 23.4 | 0.5 | 0.0 | 0.0 | 0.6 | 0.2 | POLYGON ((-77.16811 38.89652, -77.16421 38.899... |
| 1 | 51013100200 | 1.5 | 2.0 | 94706.0 | 0.1 | 1.9 | 15.9 | 29.9 | 4.9 | 2.3 | 2.5 | 14.4 | 0.7 | 0.0 | 0.0 | 2.0 | 0.1 | POLYGON ((-77.15968 38.90315, -77.15454 38.907... |
In [5]:
Copied!
# plot the data for EP_POV in a geopandas plot
arlington_svi.plot(column='EP_POV', legend=True)
plt.show()
# plot the data for EP_POV in a geopandas plot
arlington_svi.plot(column='EP_POV', legend=True)
plt.show()
Adjacency Simplicial Complex Module¶
The adjacency module provides tools for constructing adjacency-based simplicial complexes and extracting relevant topological summaries.
Key Features¶
- Constructing adjacency-based simplicial complexes
- Extracting topological summaries
- Visualizing simplicial complexes (Under development)
In [6]:
Copied!
# import the library
import spatial_tda as tda
# import the library
import spatial_tda as tda
Create the Adjacency Simplicial Complex Object from the Geospatial Data¶
In [7]:
Copied!
adjacency_simplex = tda.AdjacencySimplex(geo_dataframe=arlington_svi, variable = "EP_POV", threshold=None, filter_method='up')
adjacency_simplex = tda.AdjacencySimplex(geo_dataframe=arlington_svi, variable = "EP_POV", threshold=None, filter_method='up')
Filter and sort the Variable¶
In [8]:
Copied!
adjacency_simplex.filter_sort_gdf()
adjacency_simplex.filter_sort_gdf()
Calculate the Adjacent Counties/Census Tracts¶
In [9]:
Copied!
adjacency_simplex.calculate_adjacent_countries()
adjacency_simplex.calculate_adjacent_countries()
Create the Simplicial Complex using the Adjacency Matrix¶
In [10]:
Copied!
adjacency_simplex.form_simplicial_complex()
adjacency_simplex.form_simplicial_complex()
Calculate the Persistent Homology and get the TDA summary for the study area(Arlington County, VA)¶
In [11]:
Copied!
summaries = adjacency_simplex.compute_persistence()
summaries = adjacency_simplex.compute_persistence()
In [12]:
Copied!
print(summaries)
print(summaries)
{'H0': 57, 'TL': 435.9000000000001, 'AL': 7.647368421052633, 'TML': 217.95000000000005, 'AML': 3.8236842105263165}
Plot(GIF) the Simplicial Complex that generated from Adjacency Simplex Method¶
In [ ]:
Copied!
adjacency_simplex.plot_simplicial_complex()
adjacency_simplex.plot_simplicial_complex()