Skip to main content

A Python package for constructing synthetic geospatial networks

Project description

PySGN: A Python package for constructing synthetic geospatial networks

GitHub CI Read the Docs Codecov PyPI PyPI - License PyPI - Downloads DOI

Introduction

PySGN is a Python package for constructing synthetic geospatial networks. It is built on top of the NetworkX package, which provides a flexible and efficient data structure for representing complex networks and GeoPandas, which extends the datatypes used by pandas to allow spatial operations on geometric types. PySGN is designed to be easy to use and flexible, allowing users to generate networks with a wide range of characteristics.

Installation

PySGN can be installed using pip:

pip install pysgn

Usage Example

Geospatial Erdős-Rényi Network

Here's a simple example of how to use the geo_erdos_renyi_network function to create a geospatial Erdős-Rényi network:

import geopandas as gpd
from pysgn import geo_erdos_renyi_network

# Load your geospatial data into a GeoDataFrame
gdf = gpd.read_file('path/to/your/geospatial_data.shp')

# Create a geospatial Erdős-Rényi network
graph = geo_erdos_renyi_network(gdf, a=3)

# Output the number of nodes and edges
print(f"Number of nodes: {graph.number_of_nodes()}")
print(f"Number of edges: {graph.number_of_edges()}")

Geospatial Watts-Strogatz Network

Similarly you can use the geo_watts_strogatz_network function to create a geospatial Watts-Strogatz network:

import geopandas as gpd
from pysgn import geo_watts_strogatz_network

# Load your geospatial data into a GeoDataFrame
gdf = gpd.read_file('path/to/your/geospatial_data.shp')

# Create a geospatial Watts-Strogatz network
graph = geo_watts_strogatz_network(gdf, k=4, p=0.1)

# Output the number of nodes and edges
print(f"Number of nodes: {graph.number_of_nodes()}")
print(f"Number of edges: {graph.number_of_edges()}")

Documentation

For more information on how to use PySGN, please refer to the documentation.

Contributing

If you run into an issue, please file a ticket for us to discuss. If possible, follow up with a pull request.

If you would like to add a feature, please reach out via ticket or start a discussion. A feature is most likely to be added if you build it!

Don't forget to check out the Contributors guide.

License

PySGN is released under the MIT License.

Acknowledgements

The algorithms implemented in PySGN are based on the following paper, with some improvements and modifications:

  • Ketevan Gallagher, Taylor Anderson, Andrew Crooks, and Andreas Züfle. 2023. Synthetic Geosocial Network Generation. In Proceedings of the 7th ACM SIGSPATIAL Workshop on Location-based Recommendations, Geosocial Networks and Geoadvertising (LocalRec '23). Association for Computing Machinery, New York, NY, USA, 15–24. https://doi.org/10.1145/3615896.3628345

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysgn-0.1.0.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

pysgn-0.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file pysgn-0.1.0.tar.gz.

File metadata

  • Download URL: pysgn-0.1.0.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pysgn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9f41cd4fc5877df8801bed03f63984995fc5464e554c41b2d99acef8e97cf705
MD5 a5663d26893c094b002fad56904391f2
BLAKE2b-256 0ccad4e644749d2c7371b5635990dcf1e37a188170cd8322b49b4c9db4025df7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysgn-0.1.0.tar.gz:

Publisher: release.yml on wang-boyu/pysgn

Attestations:

File details

Details for the file pysgn-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pysgn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pysgn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b169fbe17b7640b1c62d6096ad18201da41c70289d72d7a53f0793abca884ecd
MD5 ad1f5e107cb334f1d149d9ee77e2fbb1
BLAKE2b-256 346c1e7db871dd53b7ab7de76e73bd8e7225820fd0ebd82f7356cfe9d52fec31

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysgn-0.1.0-py3-none-any.whl:

Publisher: release.yml on wang-boyu/pysgn

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page