Re: Need to create a polygon shapefile from a binary mask... any functions that could help? [message #88887 is a reply to message #88885] |
Tue, 01 July 2014 08:31   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
rryan@stsci.edu writes:
>
> 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...
Another, possibly better (if you can understand the documentation),
alternative to the path information in the CONTOUR command is
ISOCONTOUR. This should give you want to need in a single go. Again, if
you understand what you need. The documentation obviously assumes you
do. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|