Creating a polygon border from binary grid

I have an xyz geographical file where x is lon,y is lat and z values are 1 and 0. I turned it into a grid using xyz2grd.

The areas where z=1 are my interest areas. I would like to extract points from to have polygon files that contain only the points on the border of each interest area. So not all the points where values z=1 (not sites inside the interest area), only those that are on the edge of the areas. Is it possible to do that?

I would look into psmask -D for this. You would have to feed it an xyz table consisting of only the nodes with z = 1. Something like this, perhaps:

gmt grdmath 0 NAN =
grd2xyz -s | gmt psmask -Dpolygons.txt
1 Like

It creates a lot of small polygons, not a big one surrounding the entire area, but it works for my purpose, thank you!