# File ../lib/roller/CWRP.rb, line 510
  def write_xyz(stream)
    cell_size = terrain_cell_size

    reset_progress 'Exporting XYZ', @terrain_height.size

    @terrain_height.each_with_index do |row, y|
      y_value = y * cell_size
      row.each_with_index do |height, x|
        stream.printf("%11.3f %11.3f %11.3f\n",
            (x * cell_size), y_value, height)
      end

      increment_progress
    end

    terrain_grid_size * terrain_grid_size
  end