JobS
JobS

Reputation: 61

Generate hexagon lattices graph on the world using Networkx

I want to generate a hexagon grid on the ocean for finding a shortest path.

Networkx provides lattice.hexagonal_lattice_graph which generates a graph whose nodes and edges are the hexagonal tiling of the plane.

However, I do not want to search along the edges of the hexagons, but I would like to consider the hexagons as nodes and the 6 adjacent hexagons as the neighboring nodes. In this way, there are 6 search directions from a node, as shown in this figure.

To apply this on a ship routing problem, I would generate such a graph for the earth and exclude all hexagon tiles inside land polygons, and divide the hexagons intersecting with the land polygon borders into smaller hexagons, creating a higher graph density in coastal areas.

How do I create such a hexagonal tiling graph, such that each node has edges in the six directions with Networkx?

Upvotes: 0

Views: 337

Answers (1)

JobS
JobS

Reputation: 61

Similar question is found here.

I recursively subdivided triangles of an icosahedron into smaller triangles as done in this blog. Then used Networkx to construct a graph of the vertices and edges.

Upvotes: 0

Related Questions