pygeoda 0.0.8¶
pygeoda is a python library for spatial data analysis based on GeoDa and libgeoda, It provides spatial data analysis functionalities including Exploratory Spatial Data Analysis, Spatial Cluster Detection and Clustering Analysis, Regionalization, etc. based on the C++ source code of GeoDa, which is an open-source software tool that serves as an introduction to spatial data analysis.
Quick Start¶
pygeoda is a light-weighted library and has no dependencies. It works with ESRI Shapefiles and geopandas.
>>> import pygeoda
>>> gda = pygeoda.open('./data/Guerry.shp')
>>> w = pygeoda.queen_weights(gda)
Weights Meta-data:
number of observations: 85
is symmetric: True
sparsity: 0.05813148788927336
# min neighbors: 2
# max neighbors: 8
# mean neighbors: 4.9411764705882355
# median neighbors: 5.0
has isolates: False
>>> lisa = pygeoda.local_moran(w, gda['Crm_prs'])
>>> lisa
lisa object:
lisa_values(): [0.516120231288079, 0.8182751384950308, ...]
lisa_pvalues(): [0.197, 0.013, ...]
lisa_num_nbrs(): [4, 6, ...]
lisa_clusters(): [0, 1, ...]
lisa_labels(): ('Not significant', 'High-High', 'Low-Low', 'High-Low', 'Low-High', 'Undefined', 'Isolated')
lisa_colors(): ('#eeeeee', '#FF0000', '#0000FF', '#a7adf9', '#f4ada8', '#464646', '#999999')
>>> import geopandas
>>> df = geopandas.read_file('./data/Guerry.shp')
>>>
>>> import pygeoda
>>> w = pygeoda.queen_weights(df)
Weights Meta-data:
number of observations: 85
is symmetric: True
sparsity: 0.05813148788927336
# min neighbors: 2
# max neighbors: 8
# mean neighbors: 4.9411764705882355
# median neighbors: 5.0
has isolates: False
>>> lisa = pygeoda.local_moran(w, df['Crm_prs'])
>>> lisa
lisa object:
lisa_values(): [0.516120231288079, 0.8182751384950308, ...]
lisa_pvalues(): [0.197, 0.013, ...]
lisa_num_nbrs(): [4, 6, ...]
lisa_clusters(): [0, 1, ...]
lisa_labels(): ('Not significant', 'High-High', 'Low-Low', 'High-Low', 'Low-High', 'Undefined', 'Isolated')
lisa_colors(): ('#eeeeee', '#FF0000', '#0000FF', '#a7adf9', '#f4ada8', '#464646', '#999999')