# Calculating nearest distance between 2 points and creating line between them avoiding barrier using ArcGIS Desktop? [closed]

I have 2 point datasets. One shows a number of offshore locations. The other is the location of a number of ports in the UK.

I want to get the name and distance to the nearest port for each offshore location. I am not allowed to cross over land (I have a polygon of the UK).

I am very experienced with ModelBuilder but have little to no experience with Python.

I have looked at the Near tool, but this does not allow for barriers.

The only method I can think of is:

• Create a raster that incorporates the area that all my points fall within
• Assign a value of 1 to the land and a value of 0 to the sea
• Run some sort of cost analysis

Using this method, I can't think of a way that would let me generate lines showing the "route" between my offshore points and the port locations.

I imagine a Python solution would be best, but I am open to suggestions.

## closed as too broad by PolyGeo♦Apr 10 '18 at 23:22

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• What about (Network Analyst)? – Moh Apr 4 '18 at 11:48
• @User2009 Network Analyst is not the right tool because on the sea there is no network. A raster based approach as suggested seems to be the best. – Mesa Apr 4 '18 at 11:59
• ^^ yes but you can tell network analyst to avoid certain area's (sea) – NULL.Dude Apr 4 '18 at 12:42
• Raster approach will be best as you suggested, all you need to do is wrap the logic of 1 offshore to all ports using a model iterator. Append/Merge the outputs (which you have vectorized) into a single featureclass then you can sort/query this for nearest port. Of cause none of this takes in the effect of current and travel time, it is literally the nearest port by distance. What about exclusion zones? – Hornbydd Apr 4 '18 at 15:08
• what's you mean about barrier, which kind of barrier in the ocean!? may I ask you please clear your question by picture? or represent on map what need you do exactly? – Predator X Apr 5 '18 at 4:28