Giter Site home page Giter Site logo

lin102 / smooth-shortest-path Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 2.0 50.15 MB

This algorithm is a re-implementation based on Dijkstra algorithm, added a gradient constrain for special use. For instance, in railway route planning and design the route must constantly under a certain gradient.

Home Page: https://lin102.github.io/projects/smoothpath/smoothpath.html

Python 95.28% C++ 1.49% C 2.77% Fortran 0.11% Tcl 0.32% PowerShell 0.02% Batchfile 0.02%
dijkstra-algorithm dijkstra-shortest-path gradient digital-elevation-model arcpy python arctoolbox arcmap

smooth-shortest-path's Introduction

smooth-shortest-path

The smooth shortest path

Demand: As known to us all, there are many terrific, well-developed shortest path algorithms. However, in reality, there are always more factors need to be taken into consideration. For instance, when a railway route is being planned and designing before construction, the route between the departure point and destination not only needs to be short but also need to be “smooth” which means the whole route need to be constantly under a certain gradient so the train could run safely. This algorithm is designed to solve this kind of problems.

Algorithm description: The basic idea is adding a gradient constraint to the Dijkstra algorithm. The data is a TIFF DEM raster image containing the geographic coordinates and elevation. The output is a polyline shapefile (.shp) if it exists.

Implementation and challenges:

1. Abstract DEM TIFF to graph The shortest path algorithm should be implemented in a graph. My workflow is: a. Transfer TIFF raster to a numpy array b. Each cell has 8 connecting nodes except cells around the border (validation). [3 *3] mask. c. The transform from raster to an array will lose the geographic coordinates information. So deriving a coordinates array for distance comparison is necessary. (using Haversine formula)

2. Break condition of the Loop If there is no gradient constraint, the break condition could be all the cells are visited and the algorithm outputs global shortest paths for every pair of points in this graph. Since taking the gradient into consideration, you can not know if the start point or end point will be visited or not. So you cannot know how the final visited array would look like then there is no way to break the loop. (I still cannot think of a good way of finding the shortest path for every pair of points in the graph). Fortunately, in our case, I only need to find the shortest path for the given pair of points. It would make the condition much easier and more effective. The condition is when the endpoint is visited the loop can break, also even the endpoint is not visited but there is no node can be visited, break! which means that based on the given start and end point and the gradient threshold there is no path meet the requirement of the user. Give an error message to inform the user to try other parameters.

3. Time and space complexity by changing the break condition to if find the endpoint improved the efficiency of this algorithm a little bit. However, due to the 2-dimension searching and the characteristic of the geographic path the time complexity of this algorithm is still O(n^2). Any advice about improving this algorithm is more than welcomed.

Project structure instruction

SSDPPath.py: The main python script.

DEM data: 3 sizes of STRM DEM data for testing the algorithm. mini < clip < srtm_37_03 recommend mini for sample testing.

Path calculation tools.tbx: Arc toolbox. Can be added into ArcMap toolbox

smooth_path.mxd: Map for testing the arc toolbox

arctool box description.pdf: arctool box description

smooth-shortest-path's People

Contributors

lin102 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.