Skip to main content

Trek - Optimal Path Simulaion on Geospatial Map

Trek is a Python package that provides functionality for optimizing paths and travel times between nodes on a geospatial map, using graph theory algorithms and simulations. This package can be used to identify the best possible route between two or more points, based on factors such as distance, speed, and other constraints.

Installation

To install Trek, you can use pip:

$ python3 pip install trekpy

Usage

To use Trek, you must first create an instance of the Trek class, which takes a JSON file as input containing the geospatial map data. Once you have initialized a Trek object, you can use its methods to visualize the graph representation of the map, and to find the optimal path between two points.

Data File

Trek uses a JSON file to store the geospatial map data. The file is stored in the same directory as the Python script that uses Trek. The file name is the same as the name of the Python script.

The Location/Node Name is the keys, a hash map of latitude and longitude points are the values

  • map.json (earth)
{
    "Engineering Buiding":{
        "latitude":32.214256505009985,
        "longitude": -98.21779723918512
    },
     "Library":{
         "latitude":32.215730969726785,
         "longitude": -98.21730569278304
     },
     "Nursing Building":{
         "latitude":32.21664588196621,
         "longitude": -98.22043371534166
     },
     "Centennial":{
        "latitude":32.217553223855305,
        "longitude": -98.2217742964382
    },
     "Rec":{
         "latitude":32.21630562642345,
         "longitude":  -98.2224535241938
     },
      "Science Building":{
         "latitude":     32.216883861659866, 
         "longitude": -98.21972368519181
     },
}

-map.json (canvas)

{
    "A": {
      "x": -0.019863067642025122,
      "y": -0.943951654391012
     }, 
    "B": {
      "x": 0.8559401394488363,
      "y": -0.01622570094196981
     }, 
    "C": {
      "x": 0.1397386472898502, 
      "y": 0.9999999999999999
     }, 
    "D": {
    "x": -0.9758157190966613,
    "y": -0.03982264466701821
     }
}

QuickStart

  • env varies depends on your map data - [earth or canvas]
from trekpy.Trek import Trek     

# Initialize a Trek object
t = Trek(filename='map.json',env='earth')  # or t = Trek(filename='map.json',env='canvas')
# Get Locations
t.locations # list[str]

#Estimate time to cover a distance from start to end over a time
t.estimate_time(start='A',end='B',speed=3.1) # speed is default 3.1 - average walking speed miles per hour - returns in minutes
# Visualize the graph representation of the map
t.graph() # View Data as a Map Visually

# Distance between to points on the map
t.distance('A', 'B')

# Plot the map on a line graph
t.plot_line_graph()

# Plot the map on a dot graph 
t.plot_dot_graph()

# Manually Map out on environment
t.plot_web(port=9949)
# Find the optimal path between two points
planned = ['A', 'B', 'C', 'D', 'E'] # Places you plan to stop or visit, include start and end
start = 'A'
end = 'E'
speed = 3.1
best_sol = t.find_optimal_path(planned=planned, start=start, end=end, speed=speed)

# Visualize the optimal path on the map
t.visualize_optimal_path(best_sol['path'], best_sol['times'])

Visualization

Graph - Mapping out Data

Visualizing Optimal Path

Dot Graph

Metadata

Release files for trekpy 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trekpy 0.0.6
File Size Uploaded
trekpy-0.0.6.tar.gz 8.3 kB Details

Release files / trekpy-0.0.6.tar.gz

Download URL trekpy-0.0.6.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fb93992610cbb5d05c240c056e63c21056254372d6a251946413a31aea8a9161
BLAKE2b-256 checksum
How to use checksums
4c0b185aa02f0efbf3d392469d847d867ea801a3df82846f3f196f8d9c0add6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.0.6 This release

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page