% The browser defines the dataset region from the outer edges.
% In the following add/substract 1/2 of the pixel spacing 
% to get the center of each pixel.
PixelSpacingLatitude = abs(diff(LatRange) / Nlat);
PixelSpacingLongitude = abs(diff(LonRange) / Nlon);
PixelSpacing = 111.0 * PixelSpacingLatitude;

if LonRange(1) < LonRange(2)
  NewLlon = LonRange(1) + PixelSpacingLongitude / 2;
  StartColumn = floor((sLon - NewLlon) / PixelSpacingLongitude) + 1;
  EndColumn = ceil((eLon - NewLlon) / PixelSpacingLongitude) - 1;
else
  NewLlon = LonRange(1) - PixelSpacingLongitude / 2;
  StartColumn = floor((NewLlon - eLon) / PixelSpacingLongitude) + 1;
  EndColumn = ceil((NewLlon - sLon) / PixelSpacingLongitude) - 1;
end
if StartColumn == -1, StartColumn = 0; end
if EndColumn == Nlon+1, EndColumn = Nlon; end
% added fix, 98/04/13 D.B.
if StartColumn > EndColumn, EndColumn = StartColumn; end
if StartColumn < 0 | EndColumn <= 0 | ...
      StartColumn >= Nlon | EndColumn > Nlon
  return
end

% Construct the longitude vector in case this is an array rather than a grid. 
LonSign = diff(LonRange) / abs(diff(LonRange));
LonVector = NewLlon+LonSign*PixelSpacingLongitude*...
    (StartColumn:get_dset_stride:EndColumn);

% Now for the latitude range.
if LatRange(1) < LatRange(2)
  NewLlat = LatRange(1) + PixelSpacingLatitude / 2;
  NewUlat = LatRange(2) - PixelSpacingLatitude / 2;
  SouthLat = max(get_ranges(2,1), NewLlat);
  NorthLat = min(get_ranges(2,2), NewUlat);
else
  NewLlat = LatRange(1) - PixelSpacingLatitude / 2;
  NewUlat = LatRange(2) + PixelSpacingLatitude / 2;
  SouthLat = max(get_ranges(2,1), NewUlat);
  NorthLat = min(get_ranges(2,2), NewLlat);
end

if SouthLat >= NorthLat
  disp('No data in latitude ranges.')
  return
end

if LatRange(1) < LatRange(2)
  StartRow = ceil((SouthLat - NewLlat) / PixelSpacingLatitude);
  EndRow = floor((NorthLat - NewLlat) / PixelSpacingLatitude);
else
  StartRow = ceil((NewLlat - NorthLat) / PixelSpacingLatitude);
  EndRow = floor((NewLlat - SouthLat) / PixelSpacingLatitude);
end

if StartRow == -1, StartRow = 0; end
if EndRow == Nlat+1, EndRow = Nlat; end
% added fix, 98/04/13 D.B.
if StartRow > EndRow, EndRow = StartRow; end
if StartRow < 0 | EndRow <= 0 | ...
      StartRow >= Nlat | EndRow > Nlat-1
  return
end

% Construct the latitude vector in case this is an array rather than a grid.
LatSign = diff(LatRange) / abs(diff(LatRange));
LatVector = NewLlat+LatSign*PixelSpacingLatitude*...
    (StartRow:get_dset_stride:EndRow);

