This sounds like a fun problem. I would consider:
- Read the land boundary shp file using one of these recipes: How to install Fiona to read Shapefile attributes with OSGeo4W?. It would probably be good to read it into a Shapely geometry. I like using ogr to read shapefiles:
driver = ogr.GetDriverByName('ESRI Shapefile')
dataSource = driver.Open('landboundary.shp', 0)
layer = dataSource.GetLayer()
feature = layer # first boundary
geom = feature.GetGeometryRef()
Use NetworkX to build a network of all your lat long ship coordinates, but don't connect coordinates whose straight line connection intersects the land boundary. Here's an example to solve for the intersection of geometries: Shapely LineString and Polygon intersect?.
Then compute the least cost path using NetworkX with distance as the cost. The LCP won't cross over land because those nodes are not connected.
Also, just fyi, shapely geometries convert to WKT (well known text which is a text-based format) like this,
myShapelyGeometry.wkt, which is very easy and intuitive to parse and use how you want.
Edit: Just some extra info:
To compute the distance between two lat long coords, you can use pyproj:
geod = pyproj.Geod(ellps='WGS84')
_,_,distance = geod.inv(long_start,lat_start,long_end,lat_end)
Also, you can start a networkx graph like:
graph = networkx.Graph()
graph.add_edge('coord_a', 'coord_b', weight=distance)
# add more edges in the same way
start_node = find_closest_node(graph, lat_start, long_start)
end_node = find_closest_node(graph, lat_end, long_end)
ship_path = networkx.shortest_path(graph, start_node, end_node)