# Tag Info

4

NetworkX provides a ready-to-use library for the A* Algorithm. Basically the steps you want to take are: Read the slope (the slope numbers are the weight, the more weight the less optimal) Create the graph from the slope matrix. This is the hardest part. Feed the NetworkX lib the graph and according to docs it should do the rest. This is a canned solution ...

3

If you know, that the route should go through the blue point, then you could use pgr_dijkstraVia: https://docs.pgrouting.org/latest/en/pgr_dijkstraVia.html#pgr-dijkstravia SELECT * FROM pgr_dijkstraVia( 'SELECT id, source, target, cost, reverse_cost FROM edge_table order by id', ARRAY[1, 2, 3] ); Where 1, 2 and 3 are your vertex ID's and "2" is the ...

2

You can use Networkx library. http://networkx.github.io It can read shapefiles. Ex: import networkx graph = networkx.read_shp("path/to/your/shapefile.shp") Now you can use your graph: print graph.nodes() [(X.X, Y.Y), (X.X, Y.Y)...] There are also few alghoritms implemented: Dijkstra, Bellman-Ford, A* http://networkx.github.io/documentation/latest/...

2

Given that the graph is loading successfully and no paths are being found there are two possibilities that might cause this: NetworkX does not split lines when loading into the system as it simplifies edges to their start and end points and only where those points overlap are edges created. To fix this you will need to explode your lines, using something ...

2

It appears that AStarNodes store the cost so far in their g field so something like: cost = ((AStarNode) p.getLast()).getG(); should work or if you intend to use the whole path anyway you could do something like: List<Edge> edges = p.getEdges(); double cost = 0; for (Edge e : edges) { cost += myAstarfun.cost((AStarNode)e.getNodeA(),(AStarNode)e....

1

The cost of pgRouting is used for the cost function. In your case the cost is "score * penalty". The pgr_dijkstraCost() function is mainly for convenience, for example when you request multiple origins/destinations at the same time but are just interested in the total cost. However, if the actual aggregated cost should be a different one than the one used ...

1

For pgRouting functions you need to use the attributes that define your network topology. The network pgRouting uses has road links (unique id) with start and end node ID's (source and target node), so in your query you probably use those. osm_id is the original OSM ID, so you have a reference to your original data. The grey column on the left is just a row ...

1

Ran, Where is your PostgreSQL database housed. On BlueHost or somewhere else. You might want to check out last chapter of 2nd edition of our book which covers these topics and provides examples in PHP -- you can download the code for free has examples of Leaflet and OpenLayers with PHP http://www.postgis.us/chapter_17_edition_2 (2nd edition currently in ...

1

I think this is the expected behaviour. Consider that if there is no edge between the source node and destination node, what could the route (list of edges) possibly be?

1

I think the best way to read in a raster for any purpose with Python/GDAL is by using a scanline and the unpack struct function. The code is more compact, the control is more effective and the execution time is faster than the one with 'ReadAsArray'. The scanline/struct method depends on fmttypes and their values can be supplied in a dictionary. In the next ...

Only top voted, non community-wiki answers of a minimum length are eligible