function[streamLidarGrd] = findStreamGrdLidarExtent(streamVertices)

%create lidar data for stream reach inputs: vertices for the stream reach
%in x,y format. outputs a matrix with all lidar points within that stream
%corridor (400m on each side);
%{
load Stream_temp
streamVertices=Stream_temp;
%}

%%
%define tile sequences (3 for ground leaf on lidar)
tiles=[1 130; 131 265;];

%%
streamLidarGrdTemp=zeros(40000000,3);
 % fprintf('Process: Import Ground Lidar Data...\n\r')
 
 for data=1:2
    startTile=(tiles(data,1));
    endTile=(tiles(data,2)); 
    tileToLoad=(['load lidarData/lidarGround' num2str(startTile) '_' num2str(endTile) '.mat']);
    eval(tileToLoad);
    %%
% assign x and y values from lidar
    xvalue=(['x = lidarGround' num2str(startTile) '_' num2str(endTile) '(:,1);']);
    eval(xvalue);
    yvalue=(['y = lidarGround' num2str(startTile) '_' num2str(endTile) '(:,2);']);
    eval(yvalue);
%create matrix of Ground and ground points based upon the extent of the stream
%reach being studied...

%import matrix of stream vertices
%sort stream vertices matrix by x and y (so the max / min function works
%correctly)
streamX=(streamVertices(:,1));
streamY=(streamVertices(:,2));
streamXCoord=sort(streamX);
streamYCoord=sort(streamY);

%find max and min stream vertex coordinates
MinX=(min(streamXCoord))-1400;
MaxX=max(streamXCoord)+1400;
MinY=min(streamYCoord)-1400;
MaxY=max(streamYCoord)+1400;

lidarExtentPoly=[MinX MinY; MinX MaxY; MaxX MaxY; MaxX MinY;MinX MinY];
xv=lidarExtentPoly(:,1);
yv=lidarExtentPoly(:,2);


%%

in = inpolygon(x,y,xv,yv); 


%%
%assign stream matrix
 newLidarMatrix=(['lidarGrdTemp = lidarGround' num2str(startTile) '_' num2str(endTile) '(in,1:3);']);
     eval(newLidarMatrix);
%% 
 
 %%
 if data == 1
      streamLidarGrdTemp = lidarGrdTemp;
 else streamLidarGrdTemp = [streamLidarGrdTemp; lidarGrdTemp];
 end
 %%

end
%clean out zeros in streamLidarGrd
 streamLidarGrd=streamLidarGrdTemp;
 streamLidarGrd(~any(streamLidarGrdTemp,2),:)=[];

 %clear lidar variables / memory
 clearLidar=(['clear lidarGround' num2str(startTile) '_' num2str(endTile)]);
     eval(clearLidar);
     clear x
     clear y
     clear in
     clear streamLidarGrdTemp
     
%%
%{

plot(xv,yv,'r+','markerSize',2), hold on
plot(streamLidarGrd(1:100:end,1),streamLidarGrd(1:100:end,2),'r+','markerSize',2), hold on
plot(Stream_temp(:,1),Stream_temp(:,2),'--bo','LineWidth',1.25)
axis equal
%}

