Skip to main content

A package to determine which geometries are adjacent to each other, accounting for obstacles and gaps between features.

Project description

Geo-Adjacency

Pip repository

Full documentation

Installation

It's recommended to use a virtual environment to install this tool, since its dependencies may require different versions than what is installed on your system.

pip

Recommended installation is with pip:

python -m pip install geo-adjacency

Build from source

You must have Python 3.10-3.14 installed.

$ git clone git@github.com:asmyth01/geo-adjacency.git
$ cd geo-adjacency
$ poetry install

Or with build.

$ git clone git@github.com:asmyth01/geo-adjacency.git
$ cd geo-adjacency
$ python -m build

Example Usage

See the docs for details.

  1. Load the data. geo-adjacency expects you to provide your data as Shapely geometries. You will provide three lists: source_geoemtries, target_geometries, and obstacle_geometries. What we are analyzing is which of the source geometries are adjacent to which of the target geometries. Obstacles can prevent a source and target from being adjacent, but they do not participate in the adjacency dictionary.

  2. Create an AdjacencyEngine. In this case, we'll load the sample data which is available on Github <https://github.com/asmyth01/geo-adjacency/>_.

    s, t, o = load_test_geoms("../tests/sample_data")
       engine = AdjacencyEngine(s , t, o, True)
    
  3. Run the analysis

    output = engine.get_adjacency_dict()
    # defaultdict(<class 'list'>, {0: [1, 2], 1: [1], 2: [1], 3: [2], 6: [1], 7: [1]})
    

    The output is a dictionary. Keys are the indices of source geometries in the input list, and values are a list of indices of adjacent target geometries in the input list.

  4. You can visualize the output with a handy built-in method which uses pyplot. engine.plot_adjacency_dict(). (Source geoms are grey, targets are blue, obstacles are red. Linkages are green.

    adjancency diagram

  5. You probably will want to match the adjacency dictionary back to the original data so that you can do something cool with it.

      for source_i, target_i_list in output.items():
          source_geom = source_geometries[source_i]
          target_geoms = [target_geometries[i] for i in target_i_list]

Development

Installing dependencies

poetry env use [python version]
poetry install

Running tests

poetry run pytest tests

Running a module

poetry run python [python file]

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

geo_adjacency-1.3.2.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geo_adjacency-1.3.2-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file geo_adjacency-1.3.2.tar.gz.

File metadata

  • Download URL: geo_adjacency-1.3.2.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for geo_adjacency-1.3.2.tar.gz
Algorithm Hash digest
SHA256 ce8dc96a3c1d602951834c1f7f7e9665bd641bac9276dbbc5d8844720f79733d
MD5 487d7cbc666d0d1e16b72045ff14fc54
BLAKE2b-256 a90c046a32fa3059c8ff1f28a71c604c31291fd4f3557164d4f9c861f1b1f104

See more details on using hashes here.

File details

Details for the file geo_adjacency-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: geo_adjacency-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for geo_adjacency-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 33e0c9c4ce31fa80f384a76e813089f848bf4385c726927eec0d41f3ebf73459
MD5 3b0ce8a27d56de57690c6d98ed9a8261
BLAKE2b-256 1afcdf3f0fb64f6808d1a1651dfa4f6b24be8e8d20c83a1fa95c8f453886bbfb

See more details on using hashes here.

Supported by

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