how to save networkx to shape file? - networkx

I have searched around but still didn't find a proper tutorial about the networkx write_shp(). Currently I have the graph variable G and nodes position dictionary pos.
According to the document, the nodes and edges have to have the 'Wkb' or 'Wkt'. How could I assign this 'Wkb' to my current graph? Currently, the error pops up saying.
TypeError: 'int' object is not subscriptable
I hope to draw the map by arcgis after obtaining this shape file. Also, I hope the shape file could preserve the edges attributes if possible.

1)Replace the node name with the node coordinate.
2)Set the node and edge attributes as either int, float, or string. Tuple is not supported.
3)See this question.

Related

Matlab: Find pattern in an image given a skeletonized template

I am stuck at a current project:
I have an input picture showing the ground with some shapes on it. I have to find a specific shape with a given template.
I have to use distance transformation into skeletonization. My question now is: How can I compare two skeletons? As far as I noticed and have been told, the most methods from the Image Processing Toolbox to match templates don't work, since they are not scale-invariant and rotation invariant.
Also some skeletons are really showing the shapes, others are just one or two short lines, with which I couldn't identify the shapes, if I didn't know what they should be.
I've used edge detection, and region growing on the input so there are only interessting shapes left.
On the template I used distance transformation and skeletonization.
Really looking forward to some tips.
Greetings :)
You could look into convolutions?
Basically move your template over your image and see if there is a match, and where.
The max value of your array [x,y] is the location of your object in the image.
Matlab has a built-in 2D convolution function for this

three.js calculate surfaces of stl files

I think i have a difficult problem right here..
I want to able to get the surfaces of f.e. the orange object in this three.js example https://threejs.org/examples/?q=stl#webgl_loader_stl
i want to click with the mouse, find the correct surface, which should then be highlighted, so i make sure this was the surface i want.
(i already implemented raycaster successfully, so thats not an issue)
The intersectObject method returns an array of intersections, each of which has face property. The face contains vertex indices.
For STL files containing multiple solids, each solid is assigned to a different group, and the groups are available in the geometry object that is returned from STLLoader. Each group is defined by a range of vertex indices.
So, I think you can correlate the vertex indices returned from the raycaster with the vertex indices in the geometry groups.

Fetch outgoing edge property value between two vertices in scala gremlin

I am trying to fetch edge property value between two vertices. E.g. A-->B
A and B are two vertices and it has edge with property(name).
My code looks like:
graph.V().hasLabel(A).outE().value("name").headOption()
It gives me the property value for name.
In a given two vertices, i am getting None as output
graph.traversal().V().hasLabel(A).outE("test").outV().hasLabel(B).properties("name").headOption()
'test' - Edge Label
'name' - Edge property
Any idea what is wrong with my query.
Apologies for not being able to answer this in your comments on the previous question you asked. I think what you are looking for is:
graph.traversal().V()
.hasLabel("A").outE("test").as("x").otherV()
.hasLabel("B").select("x").properties("name");
If you just want the values of the properties on the edge you can do the following:
graph.traversal().V()
.hasLabel("A").outE("test").as("x").otherV()
.hasLabel("B").select("x").values("name");
Side Note (Why is your original traversal wrong): Your original traversal:
graph.traversal().V().hasLabel(A).outE("test").outV().hasLabel(B).properties("name").headOption()
is doing the following:
Get all vertices with the label "A"
From those vertices follow the outward going edges which have the label "test" to vertices which have the label "B"
Then get the property "name" from those vertices
You are actually asking for the properties on the vertex.

How do get the edges along the path returned by dijkstra in orientdb

currently the algorithm returns only the vertices , but how to get the edges that it chose ? as there can be multiple edges between the vertices
I'll have to modify current function. Search source code 'OSQLFunctionDijkstra.java' for existing function and inside 'getDistance' method it should be easy to print 'Edge' information.

OpenStreetMap Api call returns empty set

I am trying to call OpenStreetMap API:
http://api.openstreetmap.org/api/0.6/map?bbox=43.65,-79.38,43.66,-79.37
It returns no error, but map is empty:
Do you have any ideas why?
thanks
I think for the given request, the empty dataset delivered is actually the correct response.
The API documentation says api/0.6/map returns
All nodes that are inside a given bounding box and any relations that reference them.
All ways that reference at least one node that is inside a given bounding box, any relations that reference them [the ways], and any
nodes outside the bounding box that the ways may reference.
All relations that reference one of the nodes, ways or relations included due to the above rules. (Does not apply recursively, see
explanation below.)
As far as I can see, your bounding box selects a bit of Antarctica. What data did you expect?
I guess, in OSM, Antarctica is just a way, describing its outline (and maybe some research stations somewhere). If you now ask for an area in the middle of nowhere there, there are no data to get. This is because within your bbox there are no nodes. The way for the outline/area of Antarctica is only fetched if at least one of its nodes lies within your bounding box.
PS: If you want a piece of Toronto (with lots of data), swap longitude and latitude values :)
https://wiki.openstreetmap.org/wiki/Download#Construct_a_URL_for_the_HTTP_API
it says the bounding box can only be 0.5 by 0.5 degrees. it also says you might want to try XAPI for such a large area