Re: Need to create a polygon shapefile from a binary mask... any functions that could help? [message #88886 is a reply to message #88885] |
Tue, 01 July 2014 08:31   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Tuesday, July 1, 2014 5:19:51 PM UTC+2, rr...@stsci.edu wrote:
> Hi FSU
>
>
>
> I've been trying to do the same thing. I don't have anything working, but this is what I planned to try...
>
>
>
>
>
> Does the mask have multiple "masks?" Or is it just one monolithic thing? if it's just one grouping of 1s and 0s, then I think this might work... Myabe.... I haven't tried it, but this is where I was going to start.
>
>
>
> Use the contour procedure. Set the parameters to only contour the 1s. Use the XY_PATH variable to have it return the xy values of the contour. We might need to monkey around with the settings on how contour smooths (if it does).
>
>
>
> If you have multiple regions, then I think we to use label_regions in a clever way to go through and contour each region separately and default to the previous.
>
>
>
> I'm going on a trip for the Fourth, but I'll be working on this problem with my laptop. If I get anywhere, I'll drop you a line here.
>
>
>
>
>
> -Russell
>
>
>
>
>
>
>
> On Sunday, June 29, 2014 5:49:07 PM UTC-4, ca...@my.fsu.edu wrote:
>
>> Hey guys, I have a binary mask (just 1s and 0s) and I need to somehow extract the polygons (1s) out of there and convert them to a shapefile. Well all the documentation I've found seems to suggest that I need all the vertex data for each of the polygons I want to add, and I need to add them one by one... is there any other way to go straight from binary mask -> shapefile?
>
>>
>
>>
>
>>
>
>> If not, is there anyway to extract the polygons from the binary mask easily?
>
>>
>
>>
>
>>
>
>> Thank you all for the help, finding help online for IDL is painstakingly frustrating sometimes, as I'm sure you all know...
>
>>
>
>>
>
>>
>
>> Also does anyone have any examples of creating a polygon shapefile? Documentation only has examples for a point shapefile...
Hi,
if you have a set of points (1s) and want to find the polygon that cointains them, then I think that this article from David is what you want:
https://www.idlcoyote.com/ip_tips/boundary.html
Alternatively this article might also help:
https://www.idlcoyote.com/math_tips/convexhull.html
But be careful, the second one is VERY different from the first one!
Hope it helps,
Helder
|
|
|