genthalili / searoute-py

A python package to calculate the shortest sea route between two points on Earth.
Apache License 2.0
63 stars 14 forks source link

Choosing Closest Point of Water is Sometimes Wrong #9

Closed bryantek closed 1 year ago

bryantek commented 1 year ago

I don't know how prevalent of a problem this is, but sometimes picking the closest point of water is very off. When routing from just off the southern coast of Cuba to Miami, it correctly goes around Cuba. But when the origin is picked to be 50 meters inland off the southern coast of Cuba, the route now goes overland across Cuba and then through the water. And oddly along the Florida coast instead of going straight through the water.

genthalili commented 1 year ago

Hi @bryantek ,

Can you provide the example you mentioned , I'll try reproduce and see how I might fix it. Thanks!

bryantek commented 1 year ago

Hi @genthalili ,

The route from slightly inland of southern Cuba near Jucaro (-78.89777, 21.60793) to Delray Beach, Florida (-80.05446, 26.48543) goes straight north through Cuba. Starting off the coast of Jucaro still routes through Cuba. It isn't until you get to about 30 miles off the coast (-78.95600572735125, 21.243321670986955) that the routing to Delray Beach goes around Cuba. It may have to do with the barrier islands further south.

Thanks for the response!

bryantek commented 1 year ago

As with the other issue (#8 ) that I posted, I wonder if it is simply an issue of resolution of the map.

genthalili commented 1 year ago

hi @bryantek

The error is caused from the "uncompleted" network :

image

As you can see there are missing connections for Cuba coast, especially Jucaro port/area. The algorithm is looking for the closest "next" dot, and finding the one as showed by the red line, instead of green line which is far from your start point. Adding connections will automatically solve this issue.

Thanks for reporting this bug, I will need to "spring clean" the network and optimise a bit, as it will improve also the speed of algorithm when routing. Also feel free to update/fix and collaborate on improving the file : https://github.com/genthalili/searoute-py/blob/main/searoute/data/marnet_densified_v2.geojson

This bug is same as #10 as well as #8 and is planned be fixed in v1.0.10 release.

genthalili commented 1 year ago

Fixed in v1.1.0 image

LinYouMin commented 1 year ago

Thanks for this great tool!

Test the same origin and destination like below:

origin = [-78.89777, 21.60793] # Juraco destination = [-80.05446, 26.48543] # to Delray Beach, Florida route = sr.searoute(origin, destination) print("{:.1f} {}".format(route.properties['length'], route.properties['units']))

There is a missing gap between the ports and the nearest node, see attached the map.

Please advise, thanks!

searoute-01

LinYouMin commented 1 year ago

origin = [120.25694444444444, 22.616944444444446] # Port Kaohsiung, Taiwan destination = [139.6461111111111, 35.45] # Port Yomihama, Japan route = sr.searoute(origin, destination) print("{:.1f} {}".format(route.properties['length'], route.properties['units']))

Similar issue as above. Is it becuase the network behind is a coarser one, or how I could make it better?

Thanks!

searoute-02

genthalili commented 1 year ago

hi @LinYouMin,

Please refer to the documentation and parameters you can use, for your case you need to set append_orig_dest=True, and if you want to have ports, you need this as well include_ports=True. By default they are both disabled (set to False).

For the second question, note that the network is not perfect smooth yet, and yes the network can be improves, however this requires quite some work (manual or not). Also when the network is too detailed, we might loose in speed, which might take longer for the algorithm to proceed.

Hope this answers your questions.

LinYouMin commented 1 year ago

Thanks for your prompt advice and it works perfectly.

I'll take a look of the GeoJson behind. Thanks!

LinYouMin commented 1 year ago

I got a better idea about the issue of the sencond question.

May I ask what the relationship between this Json file with Pub151 and also the marnet GeoJson package files, ex: marnet_plus_5km.gpkg?

The question is regarding to the strategy to calculate the port distance:

When I try to calculate the distance between port A and B, shall I refer to the Pub151 as the first step. If there is not a corresponding entry in Pub151, then I'll need to compute the distance using searoute that based on the Json model?

If the Json file is not good enough, then I shall try to improve the Json file, say, by adding some coastal line and the intersection nodes with existing line segements.

Sorry, I continue to use this closed issue for further related questions.

searoute-03