A new raster-based least-cost path analysis algorithm is proposed in this article that considers the critical length of grades as a parameter-governing factor that ascertains whether a path is traversable in hilly terrains. Our proposed algorithm uses a speed prediction model to predict the speed of trucks after each path segment based on an initial speed, gradient value, and length of the segment. We also consider earthwork operations, slope thresholds, and moving-window models. After applying the proposed algorithm to real-world data, a traversable path is obtained; previous studies cannot guarantee such a capability. By comparing this proposed algorithm with the latest least-cost path algorithm, we found that it offers a longer path in upward slopes to compensate for the speed of trucks. Speed profiles also reveal that trucks cannot traverse paths suggested by the existing algorithm in hilly terrains, and they stop in the middle of the road. However, in the proposed algorithm, vehicles traverse the path while compensating for speed on upward slopes. This algorithm can be used by road designers in GIS software.