rasterzones!

rasterzones!(GI::GItype, shapes::Vector{GMTdataset}, fun::Function)

keywords: GMT, Julia, zonal statistics

Apply a unidimensional function fun to to the elements of the grid or image GI that lies inside the polygons of the GMTdataset shapes. The GI array is modified in place.

  • GI: A grid (GMTgrid) or image (GMTimage) type that will be modified by applying fun to the elements that fall inside the polygons of shapes.

  • shapes: A vector of GMTdataset containing the polygons inside which the elements if GI will be assigned a single value obtained by applying the function fun.

  • fun: A unidemensional function name used to compute the contant value for the GI elements that fall inside each of the polygons of shapes.

Returns

It does't return anything but the input GI is modified.

Examples

Take the Peaks grid and replace the elements that fall inside a triangle at the center by their average.

using GMT

G = GMT.peaks();
D = mat2ds([-1 -1; 0 1; 1 -1; -1 -1]);
rasterzones!(G, D, mean)
viz(G)

See Also

colorzones!