function Z = make_land(Z,NX,NY,i0,j0,r,h)

% random, but fixed seed, so should be repeatable
%r = RandStream('mt19937ar', 'seed',3);
r = RandStream.getDefaultStream();
depth = 1;
factor = 20; %0.25;

for k = 1:depth
    % choose a random splitting plane
    x1 = r.randi(round(NX / 1));
    x2 = r.randi(NX);
    y1 = r.randi(round(NY / 1));
    y2 = r.randi(NY);
    
    % pulled out of loop for optimization
    xy1 = sqrt((x2-x1)^2 + (y2-y1)^2);
    
    % raise/lower land based on splitting plain
    for i = 1:NX
        for j = 1:NY
            x0 = i;
            y0 = j;
            % project point (x0,y0) onto line (x1,y1), (x2,y2)
            d = ((x2 - x1) * (y1 - y0) - (x1 - x0) * (y2 - y1))/xy1;
            if (d < 0)
                Z(i,j) = max(Z(i,j) - factor, 0);
            else
                Z(i,j) = min(Z(i,j) + factor, 135);
            end
        end
    end
end