Re: calculate distance offshore (from a coast)

From: Dave Allured - NOAA Affiliate <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Fri Jul 26 2013 - 13:51:06 MDT

Sam,

Okay, good luck. If by any chance you can get the GSHHS data in
shapefile format, that program also includes a shapefile reader that
can pick out individual polygon "features" from a collection. FWIW.

--Dave

On Fri, Jul 26, 2013 at 11:40 AM, Sam McClatchie (NOAA Federal)
<sam.mcclatchie@noaa.gov> wrote:
> Hi Dave
>
> Thanks for the code. A colleague here is generating a coastline without
> islands, and I am still trying to decide whether to modify our R function to
> estimate distances from a coast (or point) to use modified GSHHS data, or
> whether to do it with NCL. The only problem is that our R function uses a
> binary GSHHS file and we can't seem to get the modified island-less GSHHS
> data file back into binary format.
>
> Again, thanks for your response to my query.
>
> Sam
>
>
>
> On 07/25/2013 02:11 PM, Dave Allured - NOAA Affiliate wrote:
>>
>> Sam,
>>
>> Are you asking for the CLOSEST distance from a point to the coastline?
>> If so, then please consider the attached working NCL program that I
>> wrote a while ago. This could be simplified and adapted to your
>> question. The program is somewhat complicated and messy because I
>> made it for a specific batch application, multiple points and multiple
>> polygons. However, in the middle of nested loops there is a
>> functional algorithm to compute closest distance.
>>
>> The method is about the same as what you and Dennis suggested, so this
>> is merely a working example. Traverse a list of lat/lon coordinates
>> of border line vertices, and use gc_latlon and a min function to find
>> the smallest point to point distance.
>>
>> This method works well with high resolution polylines, where the point
>> to polyline distance is much larger than the point to point spacing
>> along the polyline. However, there is a potential error if there is a
>> long single line segment, and the closest approach of the test point
>> is actually along this line segment. This simple method will miss the
>> closest mid-line approach, and overestimate the final result for
>> closest distance.
>>
>> If necessary, the missing step could be added. One would need to
>> first test whether the point lies "next to" each line segment, or off
>> one or the other end of the segment. Then, only for "next to"
>> segments, compute the minimum point-to-line distance. On the sphere,
>> the algorithms for both parts of this are rather complicated, so I
>> skipped this completely in my program.
>>
>> Another caveat is exactly what you mean by "coastline". You may have
>> a shapefile or other coastline source that includes multiple
>> coastlines, including islands and so on. You would need to select a
>> specific polyline element if there is a risk of getting the closest
>> distance to the wrong feature.
>>
>> Please excuse this rambling message. I had to think through this
>> earlier, and some of this might be helpful for your problem.
>>
>> --Dave
>>
>> On Wed, Jul 24, 2013 at 11:05 AM, Sam McClatchie (NOAA Federal)
>> <sam.mcclatchie@noaa.gov> wrote:
>>>
>>> Colleagues
>>>
>>> I there a convenient way to calculate the distance of a point from the
>>> coast
>>> in NCL, given a projection? I know the function gc_latlon will give me
>>> the
>>> great circle distance between two points, or two arrays. So I expect the
>>> answer is to extract the coordinates from the coastline, convert to a an
>>> array variable, and then use gc_latlon to calculate the distance between
>>> the specified locations array and the coastline array. Is this the way to
>>> proceed, or is there a distance from coast function, please?
>>>
>>> Best fishes
>>>
>>> Sam
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jul 26 13:51:19 2013

This archive was generated by hypermail 2.1.8 : Thu Aug 01 2013 - 15:55:04 MDT