Skip to main content

Simplificacion de grafos urbanos y analisis de criminalidad

Project description

ACJ: Urban Graph Acceleration & Simplification Framework

Python C++ PyPI License

ACJ is a high-performance hybrid C++/Python framework for the semantic and topological simplification of large-scale urban street networks. It safely decouples topology from semantic metadata (speed limits, road names, etc.) so that both survive massive graph reductions powered by a CGAL-accelerated C++ core.


Installation

ACJ is published on PyPI and ships with pre-compiled wheels for Linux, macOS (Apple Silicon & Intel), and Windows. No C++ compilation required.

pip install geojac

For GPU-accelerated real-time visualization, install the optional extras:

pip install "geojac[viz]"

We recommend working inside a virtual environment: python -m venv venv && source venv/bin/activate


Quick Start — End-to-End Pipeline

import osmnx as ox
from geojac import UrbanNetwork, ACJTopologicalEvaluator
from geojac import CompressionRatioMetric, SemanticSpeedDistortionMetric

# 1. Fetch a raw street network
G = ox.graph_from_place("Barranco, Lima, Peru", network_type="drive")

# 2. Parse into the ACJ registry
network = UrbanNetwork.from_networkx(G)
print(network)
# <UrbanNetwork | Nodes: 312 (Meta: True) | Edges: 847 (Meta: True)>

# 3. Configure metrics and run the evaluator
metrics = [CompressionRatioMetric(), SemanticSpeedDistortionMetric()]
evaluator = ACJTopologicalEvaluator(network, metrics)
results = evaluator.evaluate()

print(results)
print(evaluator.simplified_network)

API Reference

UrbanNetwork — Core Data Container

The central data structure. Stores topology in Pandas DataFrames and semantic attributes in dictionaries, keeping them decoupled for safe C++ operations.

from geojac import UrbanNetwork

# From an OSMnx / NetworkX graph
network = UrbanNetwork.from_networkx(G)

# From raw DataFrames
# nodes_df must have columns: node_id, x, y  (+ any metadata columns)
# edges_df must have columns: segment_id, node_start, node_end  (+ any metadata columns)
network = UrbanNetwork.from_dataframe(nodes_df, edges_df)

Key attributes:

Attribute Type Description
nodes_df pd.DataFrame Node topology: node_id, x, y
edges_df pd.DataFrame Edge topology: segment_id, node_start, node_end
node_metadata dict Per-node semantic attributes keyed by node_id
edge_metadata dict Per-edge semantic attributes keyed by segment_id

MapIndex — Spatial Queries

CGAL-backed spatial index for fast nearest-neighbor point-to-graph assignment. Useful for correlating events (e.g., crime incidents) with street segments or intersections.

from geojac import MapIndex, load_graph
import pandas as pd

graph_data = load_graph(nodes_df, edges_df)
index = MapIndex(graph_data)

# Assign point events to the nearest node
points = pd.DataFrame({'point_id': [1, 2], 'x': [-77.02, -77.03], 'y': [-12.15, -12.14]})
node_assignments = index.assign_to_endpoints(points)
# Returns original DataFrame + 'assigned_node_id' and 'distance' columns

# Assign point events to the nearest edge segment
segment_assignments = index.assign_to_segments(points)
# Returns original DataFrame + 'assigned_segment_id' and 'distance' columns

ACJTopologicalEvaluator — Simplification Lifecycle

Automates the full pipeline: injects the network into the C++ core, receives the simplified topology with lineage maps, runs semantic resolution, and applies metrics.

from geojac import ACJTopologicalEvaluator, CompressionRatioMetric, SemanticSpeedDistortionMetric

evaluator = ACJTopologicalEvaluator(network, metrics=[
    CompressionRatioMetric(),
    SemanticSpeedDistortionMetric(),
])
results = evaluator.evaluate()

simplified = evaluator.simplified_network  # UrbanNetwork

Built-in metrics:

Class Measures
CompressionRatioMetric Node/edge reduction ratio after simplification
SemanticSpeedDistortionMetric Speed-limit distribution distortion introduced by edge merging

Visualization (optional viz extra)

GPU-accelerated interactive tools built on VisPy/OpenGL. Requires pip install "geojac[viz]".

from geojac import MapIndex, load_graph
from geojac import render_graph, render_heatmap, render_comparison

graph_data = load_graph(nodes_df, edges_df)
index = MapIndex(graph_data)

# Render the raw street network
render_graph(index)

# Render a heatmap of point assignments over the network
render_heatmap(index, assignments=node_assignments)

# Side-by-side comparison of two networks (e.g., original vs. simplified)
render_comparison(
    index_original, index_simplified,
    title_left="Original", title_right="Simplified"
)

Interactive controls (all render functions):

Key Action
N Toggle node layer
L Toggle segment layer
G Toggle grid
R Reset camera view
Q / Esc Close window

load_graph / load_map — Data IO

from geojac import load_graph, load_map

# Build a GraphData object from DataFrames (required input for MapIndex)
graph_data = load_graph(nodes_df, edges_df)

# Load from a file path (GeoJSON, Shapefile, etc.)
graph_data = load_map("path/to/network.geojson")

Developer Installation (From Source)

Required: CMake ≥ 3.15, C++17, CGAL, Boost, pybind11.

# Ubuntu/Debian
sudo apt-get install cmake libcgal-dev libboost-all-dev

# Arch Linux
sudo pacman -S cmake cgal boost pybind11
git clone https://github.com/CdeCasurpie/CS5351-acj.git
cd CS5351-acj
python -m venv venv && source venv/bin/activate
pip install -U pip setuptools wheel
pip install -e .

Academic Team & Acknowledgements

This framework was developed as part of a thesis research project at the Universidad de Ingeniería y Tecnología (UTEC).

Lead Researchers & Engineers:

  • Alejandro Calizaya
  • Cesar Perales
  • Jerimy Sandoval

Thesis Advisors:

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

geojac-0.2.2.tar.gz (70.7 kB view details)

Uploaded Source

Built Distributions

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

geojac-0.2.2-cp313-cp313-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.13Windows x86-64

geojac-0.2.2-cp313-cp313-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

geojac-0.2.2-cp313-cp313-macosx_26_0_arm64.whl (946.1 kB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

geojac-0.2.2-cp312-cp312-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.12Windows x86-64

geojac-0.2.2-cp312-cp312-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

geojac-0.2.2-cp312-cp312-macosx_26_0_arm64.whl (946.0 kB view details)

Uploaded CPython 3.12macOS 26.0+ ARM64

geojac-0.2.2-cp311-cp311-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.11Windows x86-64

geojac-0.2.2-cp311-cp311-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

geojac-0.2.2-cp311-cp311-macosx_26_0_arm64.whl (944.9 kB view details)

Uploaded CPython 3.11macOS 26.0+ ARM64

geojac-0.2.2-cp310-cp310-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.10Windows x86-64

geojac-0.2.2-cp310-cp310-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

geojac-0.2.2-cp310-cp310-macosx_26_0_arm64.whl (943.8 kB view details)

Uploaded CPython 3.10macOS 26.0+ ARM64

File details

Details for the file geojac-0.2.2.tar.gz.

File metadata

  • Download URL: geojac-0.2.2.tar.gz
  • Upload date:
  • Size: 70.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geojac-0.2.2.tar.gz
Algorithm Hash digest
SHA256 98264989351b5a551202dff4340dbda6ea04affd0c18a6acbd2d03e70c36ed1d
MD5 ddafac4562d61724813d280db73ec50c
BLAKE2b-256 a21d1843d41e5ed95876e389570000002dddca20ee9d9d60efce16ff7d721a58

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: geojac-0.2.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geojac-0.2.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7e9f245ebd3611793747385374de7e206612d7d5472d3abc7efd822e9a02cc2b
MD5 45a89cfacf32422a089f798d8ac0e679
BLAKE2b-256 bdb71857491150f6eb3f12f47adcc3c176a00088def654b08a6c7b4f11ce64df

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for geojac-0.2.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0d9d950c07693e6f0e4ce907d01dc870b2d71ca886e978b16975dcb49c931efd
MD5 d22cd81843bd972aab43f82b5b9fae28
BLAKE2b-256 0c8cef583c43d7091ae7a7d5ec3949c413fdd4704ed3052ec97290671efb3ba9

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp313-cp313-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for geojac-0.2.2-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 759297361207da832db4180c8c8403d8d30191a257ad443dffaaa671fc932852
MD5 2796d5832a425ec1094c8d85a5752102
BLAKE2b-256 048fa761fc112feef740f369041826c0dfa86d15424af8d03bae23465ed03872

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: geojac-0.2.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geojac-0.2.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1c7ec7702cd539013559187ce55b002fd71d1a0ce5364048e1fb399d2ebd1eb6
MD5 9584ae49828305ea8b2c2168ff53fc57
BLAKE2b-256 9ba9574296b111ff9ca3bc4490f6abbb87cedfc0d74b75cbe602b8a41f9ea893

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for geojac-0.2.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 efb56e2a1ea09ca60ac9aeec3af2c85705b16d27d89c2e469ef65918a1f29bab
MD5 584f53af9f912129562ed0c698ccf3dd
BLAKE2b-256 e24c6e6eedbcf3fc5cf933e38bf26e53795552480503f87f6289d88e33c2c7fe

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp312-cp312-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for geojac-0.2.2-cp312-cp312-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 f30614a6a6b8f08436e74466e86d48890f1220b8c16452823014a84753c39d9d
MD5 64514b6d6b17378ce36905014d52c1cb
BLAKE2b-256 ac1dd70087d64878ff89bdcbf0199893f1a2978bb795b12ac1db7026237e1757

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: geojac-0.2.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geojac-0.2.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3663994be698c3a96fd0da74d6b5d1cd569f9f8a3cac299c7aa239cf62f81ddf
MD5 4edfac8a482b2ef2259c0921c00fedb3
BLAKE2b-256 cfccb71e3aaf68da817a8a970f7246c729cbad20a3e42844ccff160ade0d228d

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for geojac-0.2.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 16280869c0d725e52b56f7d7e26fceaac0814c5453c31b81d6c705719c290b38
MD5 51398543ab001dbc255b0c7196a6d2a6
BLAKE2b-256 88146bfd4ce1a29b12d1f79ae9c7c09c982d321db9d05fbee3815b8b08cdd158

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp311-cp311-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for geojac-0.2.2-cp311-cp311-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 3c30526d7e00539f8e84270c78eaa51ee11ac16faa11b3e3ad9131d4c171a87e
MD5 19f3ea5dd545a7727ccc6b2d2f309c15
BLAKE2b-256 6f88b66113a3c2012c4bc8ed83d9c296f0848efd18ffc3058c58ff6a28d26f0f

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: geojac-0.2.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for geojac-0.2.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8949238474d0d29888e50b6e4a6e640598b6ca2392c2729d7d9bc6e13a0e9b3a
MD5 6fcee758435dfc32085a78ae44436ec3
BLAKE2b-256 e4d518c1ccd2d7644ad6fa4bc6e12c938e6c944a93cb55ab475f8ffcf4c9acf0

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for geojac-0.2.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 02a59f50873e6ff5d6149011857760f3fe7dd5bdf40de0a8d10ea8ae0ad1ec65
MD5 233b57f346afc9491d0d047af1dfe5d8
BLAKE2b-256 709dc2433e4d3c44e1f7213363cc2554379375d714e92dbaf467787601b4e411

See more details on using hashes here.

File details

Details for the file geojac-0.2.2-cp310-cp310-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for geojac-0.2.2-cp310-cp310-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 54376e94e0295a586736c2c034b3f52ebc36ea74d4fbf90f9ba6f2d468bdd7b4
MD5 dffb07f33c26bb163f89e70a1860e281
BLAKE2b-256 a94503aa97c3225018c123c382ddd96abbe534c767c6480f586d18074bf80a28

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